Reputation: 35
I'm trying to get IPv4 only from my computer which has multiple IPv4 addresses. The output contains IPv6 also as below:
10.24.21.115
fe80::8029:4127:55a6:4328
192.168.0.2
fe80::ac59:de9a:c9db:b5d8
Tried filtering like $_.ipaddress -notlike "fe80*" and many more...
Get-WMIObject Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=TRUE' | where { $_.ipaddress -notlike "fe80*" } | select-object -ExpandProperty IPAddress
Expected output as : 10.24.21.115, 192.168.0.2
Upvotes: 0
Views: 2721
Reputation: 24585
How about
Get-WmiObject Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=TRUE' |
Select-Object -ExpandProperty IPAddress |
Where-Object { $_ -match '(\d{1,3}\.){3}\d{1,3}' }
Upvotes: 1