#188300 - 2008-06-20 09:55 AM
Re: Help with nslookup output
[Re: Glenn Barnas]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
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.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|