# get-hostaddress.ps1
# Sample using PowerShell
# Thomas Lee - tfl@psp.co.uk
# takes a parameter
Param ([string] $hostname = "www.microsoft.com")
# Get IP address
$ips = [System.net.Dns]::GetHostAddresses($hostname)
# Display results
"GetHostAddresses({0}) returns:" -f $hostname
foreach ($ip in $ips) {
" {0}" -f , $ip
}
This script (called with no parameters displays the following output:
PS C:\Documents and Settings\LeeT> D:\foo\get-hostaddress.ps1
GetHostAddresses(www.microsoft.com) returns:
207.46.193.254
207.46.19.190
207.46.19.254
207.46.192.254