≡ Menu

PowerShell: Resolving DNS names(Name to IP & IP to Name)

This is a tiny post and I am going to talk about DNS name resolution using using PowerShell. Using this you can resolve hostname to IP address and IP address to hostname. For demonstration purpose, I will use google.com for name resolution.

To resolve a DNS name to IP address:

[System.Net.DNS]::GetHostAddresses("google.com")

Similarly to resolve IP name to DNS name, try the below.

[System.Net.DNS]::GetHostByAddress("1.2.3.4")

This works for internal name resolutions as well. All you need to do is configure your internal DNS server IP address in the network connector properties.

Hope this helps.

 

{ 2 comments… add one }
  • Graham March 14, 2016, 3:12 am

    Thanks that’s quite simple to lookup. Using Get-DnsServerResourceRecord you have to know the DNS server. This way you don’t.
    Ta

  • Shirley April 23, 2016, 3:48 am

    Glad I’ve finally found soheimtng I agree with!

Leave a Comment