There are multiple ways to get it. Some will suggest using ping.exe also. But below is the tested and clean approach to do it.
Replace your host name below and test it at your end :
Hope you like this tip, do write your comments and suggestions.
Life is good!
Replace your host name below and test it at your end :
function GetIPAddress([string] $HostName) { trap { return 0 } $IP_ADDRESS=$([System.Net.Dns]::GetHostAddresses("$HostName")).IPAddressToString return $IP_ADDRESS } echo $(GetIPAddress "ABCHOSTNAME")
Hope you like this tip, do write your comments and suggestions.
Life is good!
function GetIPAddress([string] $HostName)
ReplyDelete{
(resolve-hostname $hostname).ipaddress
}
seems a little easier