Hi
I need to search an event log during the last hour for a specific event ID. Now not being a scripter I've managed to cobble together a script to will search during the last day but I need it to search for during the last hour.
any help will be received with great thanks.
strComputer = "."
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = date
dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and " & "EventCode = '46201' and " & " TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")
I need to search an event log during the last hour for a specific event ID. Now not being a scripter I've managed to cobble together a script to will search during the last day but I need it to search for during the last hour.
any help will be received with great thanks.
strComputer = "."
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = date
dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' and " & "EventCode = '46201' and " & " TimeWritten >= '" & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")