how to pass the parameter to powershell script in Windows.TimedScript.ThreeStateMoni torType

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!


July 22nd, 2015 3:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics