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.
May 2, 2013
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:
About the Author
You May Also Like