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 thought on “PowerShell: Finding IP Address”
Here’s a better option showing which NIC the IP is assigned to:
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .