So to understand properly. Running the powershell command will give me all interface with an ipv4, which is good.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.This command assumes you want IPv4 only, and not IPV6. If you want both, remove the first Where-Object filter.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
How you want to use this is up to you. I'd use something like......and pipe this into the first command (using interface index as the key) to fetch the IP addresses.Code:
Get-WmiObject -Class MSFT_NetAdapter -Namespace root\StandardCimv2 | Sort-Object -Property InterfaceIndex | Format-Table -Property InterfaceDescription, Name, Virtual, InterfaceIndex, InterfaceType, State -AutoSize
Use a WebParser to take the PowerShell output and chop it up as needed for display.
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
Statistics: Posted by nodiaque — Today, 3:24 pm