Tech Support Forum banner

WMI Scripting

1122 Views 0 Replies 1 Participant Last post by  damien82517
I need to be able to pull off a custom windows event log using VBS script...
The script below works fine for App, Sec and Sys logs... but doesnt see the custom event log that is also present on the PC.
Any one have any ideas on how to amend this to located this extra log?


strComputer = WScript.Arguments(0)

strYear = DatePart("yyyy",Date)
strYear = Right(strYear, 2)
If DatePart("m",Date) < 10 Then
strMonth = 0 & DatePart("m",Date)
Else
strMonth = DatePart("m",Date)
End If
If DatePart("d",Date) < 10 Then
strDay = 0 & DatePart("d",Date)
Else
strDay = DatePart("d",Date)
End If
strDate = (strDay & strMonth & strYear)


Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate, (Backup, Security)}!\\" & strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery("Select * from Win32_NTEventLogFile")

For Each objLogfile in colLogFiles
objLogFile.BackupEventLog("\\" & strComputer & "\c$\Temp_Logs\" & strDate & "_" & strComputer & "_" & objLogFile.LogFileName & ".evt")

wscript.echo objLogFile.LogFileName
Next
See less See more
Status
Not open for further replies.
1 - 1 of 1 Posts
1 - 1 of 1 Posts
Status
Not open for further replies.
Top