PowerShell: Finding IP Address

There are various ways to determine the IP address that is assigned to your machine. Here is a rather unusual approach that uses text operators to filter the information out of the results provided by ipconfig.exe.

This is not the most solid way of getting to an IP address. It is, however, an interesting brain teaser illustrating the power of PowerShell:

PS> foreach($ip in (ipconfig) -like '*IPv4*') { ($ip -split ' : ')[-1]}
192.168.2.105
192.168.56.1

One Response to “PowerShell: Finding IP Address”