Posts tagged eventlogs
Windows EventLogs Backup
Jan 26th
Windows Event Logs Backup Script
strComputer = "."
strLogFolder = "C:\EventLogs"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
FolderExits(strLogFolder)
For Each objLogfile in colLogFiles
If objLogFile.FileSize > 2048 Then
strBackupLog = objLogFile.BackupEventLog _
(strLogFolder & "\" & objLogFile.LogFileName & ".evt")
End If
Next
WScript.Quit(0)
' verifies that folder exists or creates
Function FolderExits(path)
Dim objFSO
Dim tmp
Set objFSO = CreateObject("Scripting.FileSystemObject")
'tmp = GetCurrentFolder() & "\" & tmp
tmp = Split(path, "\")
path = tmp(0)
For counter = 1 To UBound(tmp) Step 1
' set new path
path = path & "\" & tmp(counter)
If Not objFSO.FolderExists(path & "\" & tmp(counter)) Then
objFSO.CreateFolder(path)
End If
Next
' return true
FolderExits = True
End Function
Windows EventLogs Clear
Jan 26th
Windows Event Logs Clear Script
strComputer = "."
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.ClearEventLog()
Next


LinkedIn
Twitter
Skype