Ato
Fri Apr 29 11:05:37 CDT 2005
See script below and note the following:
(1) serverList is a text file containing one server name per line
(2) maxLogSize is in bytes and is your log file size threshhold for backing up
(3) bkpLogPath is a folder on the server that you're backing up the event logs from
HTH,
ATO
--------------------------------------------------------------------------------------------
serverList = "C:\yourList.txt"
maxLogSize = 524288
bkpLogPath = "C:\yourFolder\"
server = SPLIT(createobject("scripting.filesystemobject").OpenTextFile(serverList).Readall,vbCrLf)
For i = 0 to ubound(server)
Wscript.echo "Processing " & server(i)
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}!\\" & server(i) & "\root\cimv2")
Set evtLogs = wmi.ExecQuery("Select * from Win32_NTEventlogFile",,48)
For Each evtlog in evtLogs
If CLng(evtlog.FileSize) > maxLogSize Then
bkpLogFileName = bkpLogPath & evtlog.LogFileName & "_" & JOIN(SPLIT(Date,"/"),"_") & ".evt"
rc = evtlog.BackupEventLog(bkpLogFileName)
If rc <> 0 Then
Wscript.Echo server(i), "error backing up " & evtlog.LogFileName & " = " & Hex(rc)
Else
evtlog.ClearEventLog()
End If
End If
Next
Next
Wscript.Quit
"h22hatch" <h22hatch.1o891o@mail.codecomments.com> wrote in message news:h22hatch.1o891o@mail.codecomments.com...
>
> Any chance someone can help me out wih a script? I need the script to
> look in a text file for a server name, connect to the server, check the
> size of the application security and system log files, if it is over a
> certain size copy it to another directory, then clear the log. After
> that, go back to the list of servers and do it for the next one.
>
> Thanks
>
>
>
> --
> h22hatch
> ------------------------------------------------------------------------
> Posted via
http://www.codecomments.com
> ------------------------------------------------------------------------
>