Board index » Visual Studio » copying event logs
|
shreyas
|
copying event logs
Visual Studio243
Trying to create a simple script that will be called by batch file to copy a server's event logs to a central location: called by "cscript evt-backup.vbs servername" ====== evt-backup.vbs========= if wscript.arguments.count < 1 then wscript.echo "Requires server name!" wscript.quit end if strComputer = wscript.arguments(0) If left(strComputer,2) <>"\\" then strComputer = "\\" & strComputer End if Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate, (Backup, Security)}!\\" _ & strComputer & "\root\cimv2") Set colLogFiles = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NTEventLogFile") For Each objLogfile in colLogFiles strBackupLog = objLogFile.BackupEventLog _ ("c:\scripts\" & substr(strComputer,2) & objLogFile.LogFileName & ".evt") Next The main portion was gotten from the technet script center, but it is receiving errors: C:\Scripts\evt-backup.vbs(11, 1) (null): 0x80041021 Line 11 begins with the "Set objWMIService" Thanks Carl - |
