Here is my present script. it reads a single column file of ip addresses and pings each one.
I’d like to have 2 columns in a csv file. ip address,hostname Have it ping the ip, but print the hostname. Your help would be greatly appreciated.
Set InputFile = fso.OpenTextFile(“h:\usr\bin\MachineList.Txt”)
Do While Not (InputFile.atEndOfStream)
HostName = InputFile.ReadLine
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Ping = WshShell.Run(“ping -n 1 ” & HostName, 0, True)
objExcel.Cells(intRow, 1).Value = UCase(HostName)
Select Case Ping
Case 0 objExcel.Cells(intRow, 2).Value = “On Line”
Case 1 objExcel.Cells(intRow, 2).Value = “Off Line”
End Select
set fso…
Set WshShell…
Set InputFile = fso.OpenTextFile(“h:\usr\bin\MachineList.Txt”)
Do While Not (InputFile.atEndOfStream)
iline=split(inputFile.ReadLine,”,”)
Ping = WshShell.Run(“ping -n 1 ” & iline(0), 0, True)
objExcel.Cells(intRow, 1).Value = UCase(iline(1))
if Ping=0 then z=”On” else z=”Off”
objExcel.Cells(introw,2).value=z&” Line”
‘===== end
I put the “createobject” outside the loop for efficiency. Note that ping (on win-7) gives the computer name in its output if you use the -a option, in the first line, second token, then you would not need to maintain the cross-reference, but then you need to capture the ping data.