Due to firewall constraints, the servers I deal with do not reply to a ping, but do give their IP address
for eg, if I do :
ping myhost.com
I get
Pinging myhost.com [192.1.1.1] with 32 bytes of data:
Request Timed Out.
How can I just get the IP of the server from powershell? I know it can be done various ways if a server responds to a ping (Test-Connection or Ping-Host) , but I cant figure it when it ignores ping requests
You can use the System.Net.Dns.GetHostAddresses method.
This method will return an array of System.Net.IPAddress objects.
Examples of usage:
List all addresses:
Grab the first address in the array: