PowerShell One-liner: Quickly Finding the IP Address for Hostname and Vice Versa

If you are required to locate either the IP Address of a hostname or the hostname associated with an IP Address, use these quick PowerShell one-liners to get the job done.

Rod Trent

May 2, 2013

1 Min Read
PowerShell One-liner: Quickly Finding the IP Address for Hostname and Vice Versa

When you're curious what the IP Address of a specific hostname might be, you can use a quick PowerShell one-liner to retrieve the information.

Run the following scriptlet in the Windows PowerShell window and insert your own hostname for which you're wanting to locate the IP Address.

 

[System.Net.Dns]::GetHostAddresses("www.windowsitpro.com")

 

Output:

 

Alternatively, if someone gives you an IP Address and you'd like to determine the hostname to which it is associated, run the following scriptlet:

 

[System.Net.Dns]::GetHostbyAddress("206.72.117.68")

 

Output:

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like