' Export Hardware log of OMSA, Then clear the log.
Const CONVERT_TO_LOCAL_TIME = True
Dim shell
Set shell = CreateObject("WScript.Shell")
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
'Script.echo dtmStartDate
'Script.echo dtmEndDate
file = Date
filetxt = Replace(file,"/","")
'Script.echo "c:\" & filetxt & ".cvs"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "' And Logfile = 'System' And EventCode = '7036'")
i=0
For Each objEvent in colEvents
If objEvent.EventCode = 7036 Then
If i =0 Then
WScript.Echo "Event Type: " & objEvent.Type
shell.Run "omreport.exe system esmlog -outc c:\" & filetxt & ".csv"
shell.Run "omconfig.exe system esmlog action=clear"
i=i+1
End If
End If
Next
Const CONVERT_TO_LOCAL_TIME = True
Dim shell
Set shell = CreateObject("WScript.Shell")
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
'Script.echo dtmStartDate
'Script.echo dtmEndDate
file = Date
filetxt = Replace(file,"/","")
'Script.echo "c:\" & filetxt & ".cvs"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
& dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "' And Logfile = 'System' And EventCode = '7036'")
i=0
For Each objEvent in colEvents
If objEvent.EventCode = 7036 Then
If i =0 Then
WScript.Echo "Event Type: " & objEvent.Type
shell.Run "omreport.exe system esmlog -outc c:\" & filetxt & ".csv"
shell.Run "omconfig.exe system esmlog action=clear"
i=i+1
End If
End If
Next
No comments:
Post a Comment