Option Explicit
dim strComputer
dim objWMIService
dim colLogFiles
dim objLogfile
dim errBackupLog
strComputer = "." 'IP Address or Name
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & strComputer & "\root\cimv2")
Call eventlogbackup("Application")
Call eventlogbackup("System")
Call eventlogbackup("Security")
'Call eventlogbackup("DNS Server") Define further logs here
Function eventlogbackup(logtype)
Set colLogFiles = objWMIService.ExecQuery ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='" &logtype &"'")
For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("\\server\eventlogs\" &strComputer &"\" &logtype &".evt")
If errBackupLog <> 0 Then
Wscript.Echo "The " &logtype &" event log could not be backed up."
Else
objLogFile.ClearEventLog()
Wscript.Echo "The " &logtype &" event log is backed up."
End If
Next
End Function
2/29/2008
vbscript for backup all event logs and delete them afterwards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment