Kevin Smith
asked on
How do modify this script to backup something other than the applications event log?
I have the code below that backs up the applications event log, but instead of the applications event log I need it to back up a particular log file in the applications and services log (applications and service > softwarecompanyA).
How do I modify the code below to do it?
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate,(Ba ckup)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Application'" )
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog( "c:\script s\" & strBackupName & _
"_application.evt")
Next
How do I modify the code below to do it?
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Application'"
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(
"_application.evt")
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hmmm...Can you be more specific and give an example?
Hi, I'm not that familiar with the new eventing, but have a look at the discussion here:
https://www.experts-exchange.com/questions/26696817/Windows-2008-Server-R2-Event-log-issue.html
Basically, it looks like the wevtutil.exe command is your utility of choice, but you could also try Powershell. VBScript doesn't seem capable of querying these new event logs.
Rob.
https://www.experts-exchange.com/questions/26696817/Windows-2008-Server-R2-Event-log-issue.html
Basically, it looks like the wevtutil.exe command is your utility of choice, but you could also try Powershell. VBScript doesn't seem capable of querying these new event logs.
Rob.
ASKER
perfect, thanks :)