I am using the following script to save and clear down the event logs on a number of Win2k servers.
This currently works fine on all servers except 2. And I really cant see why this is happening.When run this script throws up a a VBScript runtime error 800A0007 Out of Memory 'getobject' error line 13 char 5 message.
There is 4gb memory on this box and I can't see why this happening. Is there any obvious that is missing form these servers thats cuasing this issue.
'Option Explicit
'On Error Resume Next
Dim strComputer
strComputer = "."
clearEVTLogs = "Yes"
Dim current: current = Now
Dim strDateStamp: strDateStamp = dateStamp(current)
strComputer = "."
strPath = objDir2 & "\"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For Each objLogfile In colLogFiles
strCopyFile = strDateStamp & "_" & strComputer _
& objLogFile.LogFileName & ".evt"
strBackupFile = "D:\LogFiles\" & strDateStamp _
& strComputer & objLogFile.LogFileName& "EventLog" & ".evt"
strBackupLog = objLogFile.BackupEventLog _
(strBackupFile)
'WScript.Echo objLogFile.LogFileName & " backed up to " _
' & strBackupFile
If clearEVTLogs = "Yes" Then
objLogFile.ClearEventLog()
End If
Next
Function dateStamp(ByVal dt)
Dim d, m, y
y = Year(dt)
m = Month(dt)
If Len(m) = 1 Then m = "0" & m
d = Day(dt)
If Len(d) = 1 Then d = "0" & d
dateStamp = d & m & y
End Function
Thanks in advance.
This currently works fine on all servers except 2. And I really cant see why this is happening.When run this script throws up a a VBScript runtime error 800A0007 Out of Memory 'getobject' error line 13 char 5 message.
There is 4gb memory on this box and I can't see why this happening. Is there any obvious that is missing form these servers thats cuasing this issue.
'Option Explicit
'On Error Resume Next
Dim strComputer
strComputer = "."
clearEVTLogs = "Yes"
Dim current: current = Now
Dim strDateStamp: strDateStamp = dateStamp(current)
strComputer = "."
strPath = objDir2 & "\"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For Each objLogfile In colLogFiles
strCopyFile = strDateStamp & "_" & strComputer _
& objLogFile.LogFileName & ".evt"
strBackupFile = "D:\LogFiles\" & strDateStamp _
& strComputer & objLogFile.LogFileName& "EventLog" & ".evt"
strBackupLog = objLogFile.BackupEventLog _
(strBackupFile)
'WScript.Echo objLogFile.LogFileName & " backed up to " _
' & strBackupFile
If clearEVTLogs = "Yes" Then
objLogFile.ClearEventLog()
End If
Next
Function dateStamp(ByVal dt)
Dim d, m, y
y = Year(dt)
m = Month(dt)
If Len(m) = 1 Then m = "0" & m
d = Day(dt)
If Len(d) = 1 Then d = "0" & d
dateStamp = d & m & y
End Function
Thanks in advance.