備忘録

気づいたことを書き留める

WMIでイベントログ取得

2008-10-13 10:28:27 | Weblog
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{(Security)}\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * From Win32_NTLogEvent Where EventType <> 4 AND EventType <> 8")

For Each objEvent in colLoggedEvents
Wscript.Echo "Category: " & objEvent.Category
Wscript.Echo "Event Code: " & objEvent.EventCode
Wscript.Echo "Message: " & objEvent.Message
Wscript.Echo "Record Number: " & objEvent.RecordNumber
Wscript.Echo "Source Name: " & objEvent.SourceName
Wscript.Echo "Time Written: " & objEvent.TimeWritten
Wscript.Echo "Event Type: " & objEvent.EventType
Next