Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1489

Help: Rainmeter Skins • Re: Get all network adapter IP

$
0
0
I doubt you will be able to successfully use this approach, unless you want to create a skin with 50+ network measures and just try every adapter index from 1 to some max number. That would certainly work. Some machines have multiple dozens of virtual adapters you'd need to ignore, so 50 measures probably will not be enough, especially in a corporate environment.

Another approach is to use a RunCommand measure to let PowerShell do all the hard work for you.

Code:

Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' } | Where-Object { $_.IPAddress -ne '127.0.0.1' } | Sort-Object -Property InterfaceIndex | Format-Table -Property IPAddress, InterfaceIndex, InterfaceAlias
This command assumes you want IPv4 only, and not IPV6. If you want both, remove the first Where-Object filter.

How you want to use this is up to you. I'd use something like...

Code:

Get-WmiObject -Class MSFT_NetAdapter -Namespace root\StandardCimv2 | Sort-Object -Property InterfaceIndex | Format-Table -Property InterfaceDescription, Name, Virtual, InterfaceIndex, InterfaceType, State -AutoSize
...and pipe this into the first command (using interface index as the key) to fetch the IP addresses.

Use a WebParser to take the PowerShell output and chop it up as needed for display.
So to understand properly. Running the powershell command will give me all interface with an ipv4, which is good.
I change the first one cause I was also getting 169.254.x.x ip to

Code:

Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' } | Where-Object { $_.IPAddress -ne '127.0.0.1' -and $_.IPAddress -notlike "169.254*" } | Sort-Object -Property InterfaceIndex | Format-Table -Property IPAddress, InterfaceIndex, InterfaceAlias
I'm honestly unsure how to put all of these into the skin. I tried checking the runcommand doc but it resulted in nothing. Is runcommand ran part of the refresh cycle or only trigger on mouse press? Cause I want something that update by itself no user interraction

Statistics: Posted by nodiaque — Today, 3:24 pm



Viewing all articles
Browse latest Browse all 1489

Trending Articles