Here is a quick way to get all IP addresses assigned to your computer:
#requires -Version 1 $ipaddress = [System.Net.DNS]::GetHostByName($null) Foreach ($ip in $ipaddress.AddressList) { $ip.IPAddressToString }
If you replace $null with a hostname (like "server123"), you can retrieve the IP address(es) assigned to that computer instead, too.
And if you are just interested in IPv4 addresses, try this:
#requires -Version 1 $ipaddress = [System.Net.DNS]::GetHostByName($null) foreach($ip in $ipaddress.AddressList) { if ($ip.AddressFamily -eq 'InterNetwork') { $ip.IPAddressToString } }