Getting your IP address(es) from a PowerShell prompt

Posted: (EET/GMT+2)

 

In the latest Windows Server versions (2012 and 2012 R2), PowerShell is more or less the default command prompt. Though you naturally can get back to the "black screen", aka the "DOS box" or simply cmd.exe, Microsoft would like to gently remind you about the existence of PowerShell (which is great in my opinion).

Now then, you have a simple need: to list your current IP address on the network (one or more). In cmd.exe, I would do "ipconfig /all", but in PowerShell, this would be against the thinking. So, what would be the correct command for this?

Try this (for IPv4 addresses):

PS C:\Users\jani> Get-NetIPAddress | where { $_.AddressFamily -eq "IPv4" } | ft -Property IPAddress

This would return a list like this:

IPAddress
---------
169.254.80.80
192.168.70.135
169.254.5.149
169.254.135.115
127.0.0.1

This neatly solves the problem. Know a shorter command? Let me know!

Oh, speaking of local IP addresses, I think today the most convenient way to find the current IP address using the graphical UI is to fire up Task Manager (always my friend), and go to the Performance tab, and from there select the network adapter you are interested in. Then on the right, you can see the current IP address, both IPv4 and IPv6, if enabled.