You can also use WMI ping to check name resolution.

I prefer this method as I am usually also checking for the state of the host so it makes sense to do both at the same time.



$oWMI = GetObject("winmgmts:root\cimv2")
For Each $sAddress in Split("10.9.99.99 foo.bar.com mail.harsco.com")
$colItems = $oWMI.ExecQuery("Select PrimaryAddressResolutionStatus,ProtocolAddress,ResponseTime,StatusCode From Win32_PingStatus Where Address='" + $sAddress + "' And TimeOut=1")
For Each $oItem In $colItems
If $oItem.ProtocolAddress="" $sResolvedAddress=$sAddress ELSE $sResolvedAddress=$oItem.ProtocolAddress EndIf
Select
case $oItem.PrimaryAddressResolutionStatus
"Could not resolve "+$sAddress+@CRLF
case @ERROR OR $oItem.StatusCode
"Cannot ping "+$sAddress+" ["+$sResolvedAddress+"]"+@CRLF
case "Default"
"Address "+$sAddress+" resolves to "+$sResolvedAddress+" and responds in "+$oItem.ResponseTime+" ms"+@CRLF
EndSelect
Next
Next


One word of warning though - this method will allow the name to be resolved by all the methods that Windows uses so for example if the name was present in you local host file then you would get a successful resolution even if the name was not present in DNS.