Hello. I am trying to backup the security log from the event viewer. I found a script from someone else, but still can not get it to work. I keep getting the Wscript.Echo "The security event log could not be backed up.". Would anyone be able to look at the script below to see if anything is missing, or have an idea why I cannot get the security log to back up? Thanks..
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup,security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Security'")
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("c:\test" & strBackupName & ".evt")
If errBackupLog <> 0 Then
Wscript.Echo "The security event log could not be backed up."
End If
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup,security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Security'")
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("c:\test" & strBackupName & ".evt")
If errBackupLog <> 0 Then
Wscript.Echo "The security event log could not be backed up."
End If
Next