Event log check
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Apr 2007 03:28:01 -0700
Hi ,
I am running a script to find the event log errors for a group of servers.
--------------------
Const ForReading = 1
Const ForAppending = 8
Const CONVERT_TO_LOCAL_TIME = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = CDate("4/3/2007")
dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate DateToCheck -7, CONVERT_TO_LOCAL_TIME
Set objTextFile = objFSO.OpenTextFile _
("C:\servers.txt", ForReading)
Set objTextFile1 = objFSO.OpenTextFile _
("C:\service_status.txt", ForAppending, True)
Set objTextFile2 = objFSO.OpenTextFile _
("C:\log_status.txt", ForAppending, True)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
strComputer = arrServiceList(0)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery("Select * from
Win32_Service")
For Each objService in colRunningServices
if objService.StartMode = "Auto" then
if objService.State= "Stopped" then
objTextFile1.WriteLine arrServiceList(0) &vbtab & objService.DisplayName &
VbTab & objService.State
End if
End if
Next
Set colEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where TimeWritten >= '" & dtmStartDate
& "' and TimeWritten < '" & dtmEndDate & "'")
For Each objEvent in colEvents
if objEvent.Type = "error" then
objTextfile2.WriteLine "Computer Name: " & arrServiceList(0) _
& vbtab & objEvent.SourceName _
& vbtab & objEvent.TimeWritten _
& vbtab & objEvent.Type _
& vbtab & objEvent.User
End if
Next
Loop
----------------------------
The problem is this script checks the logs only for the day 4/3/2007.
I want to find the log error for period of time. For example: The time now
to last 7 days. ie. 4/3/2007 to 4/10/2007..
Please help me in this.
Regards,
George.
.
- Follow-Ups:
- Re: Event log check
- From: Richard Mueller [MVP]
- Re: Event log check
- Prev by Date: File creation date. No change?
- Next by Date: Re: Event log check
- Previous by thread: File creation date. No change?
- Next by thread: Re: Event log check
- Index(es):
Relevant Pages
|
Loading