SCOM Rule contains timed script and Alert without condition


Organization demand is to running script and alert the result to forward the content to other systems.

Implementation by creating - Custom Rule that contains Data Source to running the script in every X time, and Condition (in this example the condition every time will be true) and Write Action to Alerts with Property bag content

Data Source -"Windows!Microsoft.Windows.TimedScript.PropertyBagProvider":

-<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">

<IntervalSeconds>120</IntervalSeconds>

<SyncTime/>

<ScriptName>log.vbs</ScriptName>

<Arguments/>

<ScriptBody> Option Explicit Dim oAPI,oBag,sMyScriptValue, shell Set oAPI=CreateObject("MOM.ScriptAPI") Set oBag=oAPI.CreatePropertyBag() sMyScriptValue="AlertCondition" Set shell=CreateObject("WScript.Shell") shell.LogEvent 4,"start the script" Call oBag.AddValue("MyScriptPropertyName",sMyScriptValue) Call oAPI.Return(oBag) </ScriptBody>

<TimeoutSeconds>60</TimeoutSeconds>

</DataSource>

Condition Detection - "System!System.ExpressionFilter":

-<ConditionDetection ID="CD" TypeID="System!System.ExpressionFilter">

-<Expression>

-<SimpleExpression>

-<ValueExpression>

<XPathQuery Type="String">Property[@Name='MyScriptPropertyName']</XPathQuery>

</ValueExpression>

<Operator>Equal</Operator>

-<ValueExpression>

<Value Type="String">AlertCondition</Value>

</ValueExpression>

</SimpleExpression>

</Expression>

</ConditionDetection>

Write Action - "Health!System.Health.GenerateAlert":

-<WriteAction Target="Windows!Microsoft.Windows.Computer" ID="WA" TypeID="Health!System.Health.GenerateAlert">

<Priority>2</Priority>

<Severity>2</Severity>

<AlertMessageId>$MPElement[Name="AlertMessageID81358ed3f16a45f58dfba92b78c5658b"]$</AlertMessageId>

-<AlertParameters>

<AlertParameter1>$Data/Property[@Name='MyScriptPropertyName']$</AlertParameter1>

</AlertParameters>

</WriteAction>

ScriptandAlert.xml

Comments (0)

Skip to main content