[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

VBScript error when pulling event logs

Asked by efd_support in Windows Management Instrumentation (WMI), Windows 2000 Operating System

Tags: VBScript, Windows 2000, WMI

I grabbed a script from the technet Scripting archive, and modified it as follows. It watches the event log of the server it is running on, and pulls the log entries that are errors, and inserts them into the application log of another server. It is named EventMonitor.vbs

I run this in a console window with Cscript EventMonitor.vbs

Everything went fine in our test machines, but when I switched it over to the production servers, I get an error message, "eventmonitor.vbs (7,1) SWbemServices: Access denied

The only difference I can see between the servers is the test environments are not part of the domain, but the production machine is. However the currently logged in user is part of the admin group.

I AM rather new to scripting, any assistance would be very much appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
strComputerSource = "."
strComputerDestination = "Remoteserver"
 
Set objWMIService = GetObject("winmgmts:\\" & strComputerSource & "\root\cimv2")
 
 
Set colEvents = objWMIService.ExecNotificationQuery _    
    ("Select * From __InstanceCreationEvent Where " _
        & "TargetInstance isa 'Win32_NTLogEvent'")
 
Do
    Set objEvent = colEvents.NextEvent
    If InStr(LCase(objEvent.TargetInstance.Type), Error) Then
        Wscript.Echo Now
        Wscript.Echo "Category: " & objEvent.TargetInstance.Category
        Wscript.Echo "Event Code: " & objEvent.TargetInstance.EventCode
        Wscript.Echo "Message: " & objEvent.TargetInstance.Message
        Wscript.Echo "Record Number: " & objEvent.TargetInstance.RecordNumber
        Wscript.Echo "Source Name: " & objEvent.TargetInstance.SourceName
        Wscript.Echo "Event Type: " & objEvent.TargetInstance.Type
        Wscript.Echo
	strDescr = "At " & objEvent.TargetInstance.TimeGenerated
	strDescr = strDescr & " the server encountered Description: " & objEvent.TargetInstance.Message
	set objWSHShell = Wscript.CreateObject("Wscript.Shell")
	boolRC = objWSHShell.LogEvent(1, strDescr, strComputerDestination)
    End If
Loop
[+][-]10/20/09 11:25 AM, ID: 25616965Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 02:41 AM, ID: 25737998Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625