Resolve Host Names

by Dec 24, 2009

Have you ever needed to resolve a host name to find its IP address? Simply use a .NET method and wrap it as PowerShell function:

function Get-HostToIP($hostname) {
$result = [system.Net.Dns]::GetHostByName($hostname)
$result.AddressList | ForEach-Object {$_.IPAddressToString }
}

Twitter This Tip! ReTweet this Tip!