I am new to MOM in general, and SCOM in particular, so bear with me. I have a need to run scripts periodically, and generate alerts based on their output. To test this, I have created the following script, but don't know how to set it up. What I want to do, is to schedule this to run every hour or so, raise a success event and a failure event, and generate alerts for the failure event. What is the best way to do this? Can anyone tell me how best to schedule, and monitor for the events? How do I target this so that only the management server runs this, and not all 100 servers being monitored?
The script may be wrong, but mostly I need help figuring out how to target, schedule, and raise alerts given a script that looks like the one below.
Dim strDomain, objevent, lockedusers
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16
lockedusers = 0
strDomain = "contoso"
ListUsers( strDomain )
if lockedusers = 0 then
CreateEvent 100,EVENT_TYPE_INFORMATION,"AD_USER_Acct_Locked","The check for locked users completed normally, no locked accounts found."
end if
set objcomputer = nothing
set objevent = nothing
Sub ListUsers( strDomain )
Set objComputer = GetObject("WinNT://" & strDomain )
objComputer.Filter = Array( "User" )
For Each objUser In objComputer
If objuser.IsAccountLocked Then
lockedusers = 1
CreateEvent 200,EVENT_TYPE_ERROR,"AD_User_Acct_Locked","The user account " & objuser.name & " is locked out."
end if
Next
End Sub
Sub CreateEvent(intEventNumber,intEventType,strEventSource,strEventMessage)
Set objEvent = ScriptContext.CreateEvent()
objEvent.EventNumber = intEventNumber
objEvent.EventType = intEventType
objEvent.EventSource = strEventSource
objEvent.Message = strEventMessage
ScriptContext.Submit objEvent
End Sub