Option Explicit
dim strComputer
dim objWMIService
dim colLogFiles
dim objLogfile
dim errBackupLog
strComputer = "." 'IP Address or Name
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & strComputer & "\root\cimv2")
Call eventlogbackup("Application")
Call eventlogbackup("System")
Call eventlogbackup("Security")
'Call eventlogbackup("DNS Server") Define further logs here
Function eventlogbackup(logtype)
Set colLogFiles = objWMIService.ExecQuery ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='" &logtype &"'")
For Each objLogfile in colLogFiles
errBackupLog = objLogFile.BackupEventLog("\\server\eventlogs\" &strComputer &"\" &logtype &".evt")
If errBackupLog <> 0 Then
Wscript.Echo "The " &logtype &" event log could not be backed up."
Else
objLogFile.ClearEventLog()
Wscript.Echo "The " &logtype &" event log is backed up."
End If
Next
End Function
2/29/2008
vbscript for backup all event logs and delete them afterwards
2/28/2008
vbscript to check if a computer is available
Option Explicit
dim objPing
dim objStatus
dim strComputer
strComputer="." 'IP Address or Name
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If IsNull(objStatus.ReplySize) Then
WScript.Echo "computer is offline"
'...
Else
WScript.Echo "computer is online"
'...
End If
Next
Set objPing=Nothing
Set objStatus=Nothing
What's this blog for?
welcome to my blog :)
in this blog i'll publish some technical information regarding my daily work as IT consultant.
Mainly this posts will treat the following themes:
- scripting (vbscript, vb, vba & windows scripting host, ...)
- windows (deployment, automation, 2k3, 2k8, xp & vista, ...)
- office (deployment, 2k7, ...)
- servers (sms, sql, sccm, isa, iis, ias,...)
- in summary: the daily IT doing
in this blog i'll publish some technical information regarding my daily work as IT consultant.
Mainly this posts will treat the following themes:
- scripting (vbscript, vb, vba & windows scripting host, ...)
- windows (deployment, automation, 2k3, 2k8, xp & vista, ...)
- office (deployment, 2k7, ...)
- servers (sms, sql, sccm, isa, iis, ias,...)
- in summary: the daily IT doing
so come in soon...
Subscribe to:
Posts (Atom)