Home > Scripting, Visual Basic > Script to manage Event Log files

Script to manage Event Log files

This script will check the size of the Event Log files and if any of these files will have the size greater than defined value it will back it up and then clean it.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
        & strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")
For Each objLogfile in colLogFiles
    If objLogFile.FileSize > 100000 Then
       strBackupLog = objLogFile.BackupEventLog _
           ("c:\scripts\" & objLogFile.LogFileName & ".evt")
       objLogFile.ClearEventLog()
    End If
Next
  1. No comments yet.
  1. No trackbacks yet.

Spam Protection by WP-SpamFree