Resolve Host Names

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!


Posted Dec 24 2009, 08:00 AM by ps1

Comments

Twitter Trackbacks for Resolve Host Names - Power Tips - PowerShell.com [powershell.com] on Topsy.com wrote Twitter Trackbacks for Resolve Host Names - Power Tips - PowerShell.com [powershell.com] on Topsy.com
on 12-24-2009 10:33 AM

Pingback from  Twitter Trackbacks for                 Resolve Host Names - Power Tips - PowerShell.com         [powershell.com]        on Topsy.com

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.