wmi query - use wmi to get newest Windows log events -


I want to use WMI to get every 15 minutes to monitor the Windows event log and the latest event log. However, I can use WQL to query, it does not need keywords in the order this way. Any idea how to work around this problem?

You can use a dataset. Below is only used VBScript areas ComputerName, EventCode and messages, and so on. Add desired in other areas

  Const adVarChar = 200 Const MaxCharacters = 1024 Const adFldIsNullable = 32 Set DataList = CreateObject ( "ADOR.Recordset") DataList.Fields.Append "computername", adVarChar , MaxCharacters, adFldIsNullable DataList.Fields.Append "EventCode", adVarChar, MaxCharacters, adFldIsNullable DataList.Fields.Append "message", adVarChar, MaxCharacters, adFldIsNullable DataList.Open strComputer = "." StrComputer = "." Set objWMIService = GetObject ( "winmgmts: {impersonationLevel = impersonate}! \\" & amp; strComputer & amp; "\ root \ cimv2") select set colLoggedEvents = * from objWMIService.ExecQuery ( "Win32_NTLogEvent where Logfile = 'Application' ") for ColLoggedEvents DataList.AddNew DataList (" ComputerName ") = evt.ComputerName Detalaist (" EventCode ") = evt.EventCode DataList (" message ") each evt, Iventkod DataList..Sort in = evt.Message DataList.Update by next Sort ' "EventCode DESC" DataList.EOF Wscript.Echo DataList.Fields.Item ( "ComputerName") & amp up DataList.MoveFirst Do; VbTab & amp; DataList.Fields.Item ("EventCode") & amp; VbTab & amp; DataList.Fields.Item ( "message") DataList.MoveNext loop  

Comments