I am new to vbs and cannot seem to get a script together after multiple attempts. I need to ping a server name and have the results say server DNS name such as abcd1234 is not responding and ping the same machine by IP and say IP address is not responding. Any assistance is appreciated. I am lost. Carroll.
The case would be something like
If ping staus (DNS) =0 then echo DNS is OK
else ping status (IP) =0 then echo DNS bad, IP OK
else echo cannot reach server
endif
strMachines = "abcd1234;112.12.131.123"
aMachines = split(strMachines, ";")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("Computer " & machine & " is not reachable")
End If
Next
Next
The case would be something like
If ping staus (DNS) =0 then echo DNS is OK
else ping status (IP) =0 then echo DNS bad, IP OK
else echo cannot reach server
endif
strMachines = "abcd1234;112.12.131.123"
aMachines = split(strMachines, ";")
For Each machine in aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("Computer " & machine & " is not reachable")
End If
Next
Next