I'm trying to write a script that will save all of my event logs for me on a weekly basis. I have pieced together enough that I have a working script. However, I can't firgure out how to save the log file in a .csv format. Yes, saving in the .evt format would work, boss want's it in .csv....I don't know why.
Anyway, can anyone point in the direction I need to go?
Thanks
Anyway, can anyone point in the direction I need to go?
Thanks
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Security'")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup,security)}!\\" & _
strComputer & "\root\cimv2")
For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("C:\Documents and Settings\macneill\My Documents\test\sec" & strBackupName & ".evt")
If errBackupLog <> 0 Then
Wscript.Echo "The security event log could not be backed up."
End If
Next