Powershell hostname lookup

Published by

Posted on August 03, 2016

Below are some samples on how to use GetHostEntry via Powershell. If your host is part of a domain controller and returns a unknown host error. Try pinging or traceroute to that host. Then try the lookup again.

[System.Net.Dns]::GetHostEntry(“127.0.0.1”)
[System.Net.Dns]::GetHostByAddress(“127.0.0.1”)
[System.Net.Dns]::GetHostEntry(“”)
[System.Net.Dns]::GetHostEntry(“yahoo.com”)

Per MSDN, GetHostEntry will try NETBIOS to resolve the hostname if DNS fails. This could by why your workstation returned a result.

reference : https://msdn.microsoft.com/en-us/library/ms143998(v=vs.110).aspx