You should use WMI to list all IPv4 addresses assigned to a computer:
Get-WMIObject win32_NetworkAdapterConfiguration |
Where-Object { $_.IPEnabled -eq $true } |
Foreach-Object { $_.IPAddress } |
Foreach-Object { [IPAddress]$_ } |
Where-Object { $_.AddressFamily -eq 'Internetwork' } |
Foreach-Object { $_.IPAddressToString }
You can also query remote systems this way since Get-WMObject supports -ComputerName. The trick to focusing on IPv4 only is to convert the IP address to the type IPAddress and then check that its AddressFamily is "InterNetwork."
ReTweet this Tip!
Posted
May 17 2010, 08:00 AM
by
ps1