Here is my unitmonitor code
<UnitMonitor ID="ST0001.ControllerModuleMonitor" Accessibility="Internal" Enabled="true" Target="ST0001.ControllerModule" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true"
Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="CMWARNING">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>false</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="ST0001.ControllerModule"]/CMState$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success" />
<OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error" />
</OperationalStates>
<Configuration>
<IntervalSeconds>600</IntervalSeconds>
<SyncTime />
<ScriptName>ControllerModuleScript.ps1</ScriptName>
<Arguments></Arguments>##How to get $CMState value??
<ScriptBody>
<![CDATA[
param($CMState) ##How to get $CMState value??
$api = new-object -comObject 'MOM.ScriptAPI'
$bag = $api.CreatePropertyBag()
if ($CMState -eq "Good")
{$bag.AddValue('Result','Good')}
else if($CMState -eq "Warning")
{$bag.AddValue('Result','Warning')}
else
{$bag.AddValue('Result','Bad')}
$bag
]]>
</ScriptBody>
##Here is what i want
<Parameters>
<Parameter>
<Name>$CMState</Name>
<Value>$Target/Property[Type="ST0001.ControllerModule"]/CMState$</Value>
</Parameter>
</Parameters>##Unfortunately, it does not match the schema expression!
<TimeoutSeconds>1800</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Bad</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<WarningExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Result']
</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Warning</Value>
</ValueExpression>
</SimpleExpression>
</WarningExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Good</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>
How to get $CMState value? () Thanks!
- Edited by SCOM Leaner, Internship Wednesday, July 22, 2015 3:36 AM