Windows PowerShell One Liner: Name to IP Address

PowerShell Team

<Edited 7/2/2006 to add tags and category>
Wei Wu provided a nice one liner in response to a query in our NewsGroup: Microsoft.Public.Windows.PowerShell about how to resolve a hostname into an IP Address:

PS> [System.Net.Dns]::GetHostAddresses(““)

IPAddressToString :
Address           : 1286423759
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False


If you want to go from address to name:

PS> [System.Net.Dns]::GetHostbyAddress(“”)

HostName                  Aliases                  AddressList
——–                  ——-                  ———– {}                       {}

Jeffrey Snover
Windows PowerShell Architect

PSMDTAG:FAQ: How do I resolve a hostname?


Discussion is closed.

Feedback usabilla icon