Event Log Parsing for the WSH Administrator - Polling machines across a network
(Page 3 of 4 )
Since WMI supports working with remote computers, we just need to change our script so that it polls each computer in our array in turn. To do this, we’ll need to recreate the WMI service object for each machine. We’ll begin by creating a For loop to move through the array.
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=C:events.mdb"
arrComputers = Array("machine1", _
"machine2", _
"machine3")
If objFso.FileExists("C:events.mdb") Then
oConn.Open strConnection
Else
BuildDatabase
End If
For i = 0 To UBound(arrComputers)
strComputer = arrComputers(i)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer _
& "rootcimv2")
GetEvents
Set objWMIService = Nothing
Next
oConn.Close
This simply moves through each computer name in our array, connects to the WMI Service, and then calls the GetEvents subroutine to retrieve the events on that machine.
Function Date2String(objTime)
yyyy = Left(objTime, 4)
mm = Mid(objTime, 5, 2)
dd = Mid(objTime, 7, 2)
hh = Mid(objTime, 9, 2)
min = Mid(objTime, 11, 2)
sec = Mid(objTime, 13, 2)
Date2String = mm & "/" & dd & "/" & yyyy & " " & hh & ":" & min & ":" & sec
End Function
Don’t forget to add all required subroutines to your completed script.
Next: Monitoring event logs >>
More Windows Scripting Articles
More By Nilpo/Developer Shed Staff Writer