Discussion:
Event log Query
(too old to reply)
martin
2007-10-30 21:12:25 UTC
Permalink
Hi
I am trying to query event log to check for event id A or Event id B
I can script to check for one but not two different ones
Any advice
cheers
Stephen Yorke
2008-01-28 00:31:00 UTC
Permalink
Martin,
This VBS/WMI script will allow you query for specific events, watch the code
for word wrapping:

'********************************
' Search for specific event in the Event Log
'********************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery("Select * from
Win32_NTLogEvent Where Logfile = 'Application' and EventCode = '1007' or
EventCode = '1005'")

For Each objEvent in colLoggedEvents
WScript.Echo "Category: " & objEvent.Category & vbTab & "Event Code: " &
objEvent.EventCode _
& vbCrLf & "Message: " & objEvent.Message & vbCrLf &
objEvent.TimeWritten
Next

WScript.Echo "...Complete..."
Post by martin
Hi
I am trying to query event log to check for event id A or Event id B
I can script to check for one but not two different ones
Any advice
cheers
Loading...