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

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. 

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:

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish