Link to home
Start Free TrialLog in
Avatar of Kevin Smith
Kevin SmithFlag for United States of America

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=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='Application'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_application.evt")
Next
ASKER CERTIFIED SOLUTION
Avatar of prashanthd
prashanthd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmmm...Can you be more specific and give an example?
Avatar of RobSampson
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.
Avatar of Kevin Smith

ASKER

perfect, thanks :)