Ping script

This script ping different machines. If a machine dont answer a local event will ge generated. If you set strLog to 1 a event will be generated for every successful ping.  You will need to create a parameter named Hosts that contains all hosts you want to ping.

'
' If strLog = "1" then a event will be generated for
' success ping.
'
' This script use one parameter called "Hosts".
' Value for this can be like this
' ping.sunet.se,10.1.1.0
'
' Version 2.0

aMAchines = Split(ScriptContext.Parameters.Get("Hosts"), ",")
strLog = "0"
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
Const EVENT_WARNING = 2
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_WARNING, _
"Computer " & machine & " is not reachable (" & strLog & ")"

ELSE
IF strLog = 1 Then
Const EVENT_SUCCESS = 0
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
"Computer " & machine & " is reachable"

End If
End If
Next
Next