Techibee.com

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.

 

Exit mobile version