Microsoft.Windows.PowerShellPropertyBagProbe
Applies To: Operations Manager 2007 R2
Microsoft.Windows.PowerShellPropertyBagProbe probe action module runs a Windows PowerShell script to query for information from the system and returns a returns System.PropertyBagData data.
Usage
You can use the Microsoft.Windows.PowerShellPropertyBagProbe module in a rule or a monitor.
Type Definition
<ProbeActionModuleType ID="Microsoft.Windows.PowerShellPropertyBagProbe" Accessibility="Public">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element name="ScriptName" type="NonNullString" />
<xsd:element name="ScriptBody" type="NonNullString" />
<xsd:element name="SnapIns" type ="SnapInsType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="Parameters" type="NamedParametersType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer" />
<xsd:element name="StrictErrorHandling" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<ProbeAction ID="PowerShellProbe" TypeID="Microsoft.Windows.PowerShellPropertyBagProbeBase">
<ScriptName>$Config/ScriptName$</ScriptName>
<ScriptBody>$Config/ScriptBody$</ScriptBody>
<SnapIns>$Config/SnapIns$</SnapIns>
<Parameters>$Config/Parameters$</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<OutputType>PropertyBag</OutputType>
<StrictErrorHandling>$Config/StrictErrorHandling$</StrictErrorHandling>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PowerShellProbe" />
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>
Parameters
The Microsoft.Windows.PowerShellPropertyBagProbe module supports the following configuration parameters:
Parameter | Type | Description |
---|---|---|
ScriptName |
String |
Specifies the logical name of the Windows PowerShell script to be run. This value will be used in event logs and debug traces to identify the script. |
ScriptBody |
String |
Contains the Windows PowerShell script to be run. |
SnapIns |
Optional. Contains a list of one or more Windows PowerShell snap-ins. |
|
Parameters |
String |
Specifies a set of Name/Value pairs to be used by the Windows PowerShell script as parameters. This value can be a literal string, a $Target reference, a $MPElement reference, or a $Data reference. |
TimeOutSeconds |
Integer |
Specifies the maximum number of seconds to allow the script to execute before the script is terminated. |
StrictErrorHandling |
Boolean |
Optional. Specifies whether to treat script errors as fatal errors instead of warnings. This should always be set to false in the case of discoveries and should only be true for task workflows, to allow the script error to be raised via the task status. The default value is false. |
For more information on the configuration parameters for the Microsoft.Windows.PowerShellPropertyBagProbe module, see Windows PowerShell.
Composition
The Microsoft.Windows.PowerShellPropertyBagProbe module is a composite module that contains one internal module.
Related Modules
Module Type | Usage |
---|---|
A trigger-only probe module that runs a Windows PowerShell script to query for information from the system and returns a System.PropertyBagData data type. |
External Module References
None.
Remarks
This module can be used in a monitor to run a Windows PowerShell script to determine state information about a monitored computer and return a name-value collection as a property bag.
Sample
In the following section of example code, a Windows PowerShell script is used as part of a probe to retrieve a value from the registry, add the value as a property named “State” to a property bag object, and return the property bag object to the module.
From there, the value of the returned property is checked as part of the monitor’s ErrorExpression and SuccessExpression configuration to determine the monitor’s state.
The following code shows the definition of the monitor:
<UnitMonitorType ID="Microsoft.Demo.PowerShellModule.Widget.PowerShellModule.TwoStateMonitorType.PropertyBag" Accessibility="Public">
<MonitorTypeStates>
<MonitorTypeState ID="Error" NoDetection="false"/>
<MonitorTypeState ID="Success" NoDetection="false"/>
</MonitorTypeStates>
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SyncTime" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ScriptName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ScriptBody" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SnapIns" type="SnapInsType" minOccurs="0" maxOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Parameters" type="NamedParametersType" minOccurs="0" maxOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StrictErrorHandling" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SerializationDepth" type="xsd:integer" minOccurs="0" maxOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ErrorExpression" type="ExpressionType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SuccessExpression" type="ExpressionType"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DataSource" TypeID="System!System.SimpleScheduler">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
</DataSource>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>$Config/ScriptName$</ScriptName>
<ScriptBody>$Config/ScriptBody$</ScriptBody>
<SnapIns>$Config/SnapIns$</SnapIns>
<Parameters>$Config/Parameters$</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>$Config/StrictErrorHandling$</StrictErrorHandling>
<SerializationDepth>$Config/SerializationDepth$</SerializationDepth>
</ProbeAction>
<ConditionDetection ID="ErrorFilter" TypeID="System!System.ExpressionFilter">
<Expression>$Config/ErrorExpression$</Expression>
</ConditionDetection>
<ConditionDetection ID="SuccessFilter" TypeID="System!System.ExpressionFilter">
<Expression>$Config/SuccessExpression$</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Error">
<Node ID="ErrorFilter">
<Node ID="Script">
<Node ID="DataSource"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Success">
<Node ID="SuccessFilter">
<Node ID="Script">
<Node ID="DataSource"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>
The next example shows the monitor being used with a Windows PowerShell script:
<UnitMonitor ID="Microsoft.Demo.PowerShellModule.Widget.PowerShellModule.CheckWidgetStatusMonitor.PropertyBag"
Enabled="true"
Accessibility="Internal"
ConfirmDelivery="false" Target="Microsoft.Demo.PowerShellModule.Widget.PowerShellModule" TypeID="Microsoft.Demo.PowerShellModule.Widget.PowerShellModule.TwoStateMonitorType.PropertyBag"
ParentMonitorID="Health!System.Health.EntityState">
<Category>StateCollection</Category>
<AlertSettings AlertMessage="Microsoft.Demo.PowerShellModule.Widget.PowerShellModule.CheckWidgetStatusMonitor.PropertyBag_AlertMessageResourceID">
<AlertOnState>Error</AlertOnState>
<AutoResolve>false</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="Success" ID="GreenState" />
<OperationalState HealthState="Error" MonitorTypeStateID="Error" ID="RedState" />
</OperationalStates>
<Configuration>
<IntervalSeconds>15</IntervalSeconds>
<SyncTime/>
<ScriptName>Monitor Widgets</ScriptName>
<ScriptBody>
<![CDATA[
# Always use the param statement to easily
# access parameters
param($SleepyTime)
# Get access to the scripting API
$oAPI = new-object -comObject "MOM.ScriptAPI"
# Create the property bag
$pb = $oAPI.CreatePropertyBag()
# Populate the property bag with data from the registy
$pb.AddValue("State",
(get-itemproperty hklm:/software/widgets/$Target/Property[Type='Microsoft.Demo.PowerShellModule.Widget.PowerShellModule']/Key$).State)
$pb
Write-Host "Sleeping $SleepyTime seconds starting"
Start-Sleep $SleepyTime
]]>
</ScriptBody>
<Parameters>
<Parameter>
<Name>SleepyTime</Name>
<Value>5</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>120</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="String">good</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">good</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>
Information
Module Type |
|
Input Type |
|
Output Type |
|
Implementation |
Composite |
Library |
Microsoft.Windows.Library |