PowerShell Tip: How To Get All IPs Assigned to a DNS Domain

We always use command lines like PING to get the IP address assigned to a specific domain DNS. For example, to get the IP address of google.com, we use:

ping google.com

As you can see, this only returns one of IP addresses assigned to google.com. To get the full list of IP addresses associated with google.com, you need to use a different command line like nslookup.

Or better, use PowerShell, like this shown below:

[System.Net.Dns]::GetHostEntry('google.com').AddressList.IPAddressToString

It calls up .Net DNS library and use the function GetHostEntry to get the full list of IP address associated with the specified domain DNS.

Leave a Reply

Your email address will not be published. Required fields are marked *