Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: DNS Lookup Return Multiple Host IP ADDRESS
Is it possible to query AD/DNS/etc to return back a list of ALL IPs associated with a given host? ipHost2Addr only returns one.
We are running a Win2003 environment and all DNS queries are handled internally on our Win2003 servers.
something like:
nslookup -"set q=all" TestMachine.Mydomain.comshould return the info you need.
#DefineFunction CaptureDosOutput(DosCommand) DataArray=ArrDimension(3) ;Allocate return array ArrInitialize(DataArray,"") ;initialize to all null strings oShell = ObjectOpen("WScript.Shell") ;open shell object oScriptExec = oShell.Exec(DosCommand) ;run the command ;Open output objects oStdOut = oScriptExec.StdOut oStdErr = oScriptExec.StdErr While (oScriptExec.Status==0) ;wait for completion ;Caputure StdOut data oStdOut = oScriptExec.StdOut While ! oStdOut.AtEndOfStream strLine = oStdOut.ReadLine DataArray[1] = StrCat(DataArray[1],strLine,@CRLF) EndWhile ;Capture StdErr data oStdErr = oScriptExec.StdErr While ! oStdErr.AtEndOfStream strLine = oStdErr.ReadLine DataArray[2] = StrCat(DataArray[2],strLine,@CRLF) EndWhile TimeDelay(0.1) EndWhile ;Get remainder of data, if any ;Caputure StdOut data oStdOut = oScriptExec.StdOut While ! oStdOut.AtEndOfStream strLine = oStdOut.ReadLine DataArray[1] = StrCat(DataArray[1],strLine,@CRLF) EndWhile ;Capture StdErr data oStdErr = oScriptExec.StdErr While ! oStdErr.AtEndOfStream strLine = oStdErr.ReadLine DataArray[2] = StrCat(DataArray[2],strLine,@CRLF) EndWhile DataArray[0]=oScriptExec.ExitCode ;save errorlevel/exit code ;Close handles that were opened ObjectClose(oStdOut) ObjectClose(oStdErr) ObjectClose(oScriptExec) ObjectClose(oShell) ;Return the array Return(DataArray) #EndFunction IPList = "" QueriedServer = "testMachine.mydomain.com" DosCommand = StrCat('nslookup -"set q=all" ', QueriedServer) DOSResults = CaptureDosOutput(DosCommand) DOSResults = DOSResults[1] DOSResults = StrReplace(DOSResults, @CRLF, @CR) Numlines = ItemCount(DOSResults, @CR) For i = Numlines To 1 By -1 CurrentLine = ItemExtract(i, DOSResults, @CR) If ItemLocate(StrLower(QueriedServer), StrLower(CurrentLine), @TAB) CurrentIP = ItemExtract(-1, CurrentLine, " ") IPList = ItemInsert(CurrentIP, -1, IPList, @TAB) EndIf Next Message ("The list of IP for that given host", IPList) Exit
Article ID: W18263
Filename: DNS Lookup Return Multiple Host.txt
File Created: 2009:08:27:09:49:32
Last Updated: 2009:08:27:09:49:32