Eventquery.vbs: ERROR: Unable to execute the query for the ‘security’ log

I was querying the Security log from a server with eventquery.vbs, suddenly the Microsoft script returned this error:

ERROR: Unable to execute the query for the 'security' log.

Turned out that this error appears when the Security log is over 10MB, equal to 32767 records. Got it solved by changing CInt by CLng, at Line 1700 – 170

Old code:
If CInt(objLogs.Item(arrKeyName(intLoopCount))) > 0 Then
            strFilterLog = arrKeyName(intLoopCount)
            intRecordRangeFrom = 0
            intRecordRangeTo = CLng(objLogs.Item(arrKeyName(intLoopCount))) 

New code:
If CLng(objLogs.Item(arrKeyName(intLoopCount))) > 0 Then
            strFilterLog = arrKeyName(intLoopCount)
            intRecordRangeFrom = 0
            intRecordRangeTo = CLng(objLogs.Item(arrKeyName(intLoopCount)))

 

4 thoughts on “Eventquery.vbs: ERROR: Unable to execute the query for the ‘security’ log

Leave a Reply