Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe

Applies To: Operations Manager 2007 R2

Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe trigger-only probe module runs a Windows PowerShell script to query for information from the system and returns a System.PropertyBagData data type.

Usage

This module can be used in on-demand detection scenarios; for example, when a user starts a task. This module has its TriggerOnly property set true. If you want a probe module that uses input data, use the Microsoft.Windows.PowerShellPropertyBagProbe module instead.

Type Definition

<ProbeActionModuleType ID="Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe" 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.PowerShellPropertyBagTriggerOnlyProbeBase">
          <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>
  <TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>

Parameters

The Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe 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

SnapInsType

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.PowerShellPropertyBagTriggerOnlyProbe module, see Windows PowerShell.

Composition

The Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe module is a composite module that contains one internal module.

Module Type Usage

Microsoft.Windows.PowerShellPropertyBagProbe

Runs a Windows PowerShell script to query for information from the system and returns a returns System.PropertyBagData data.

External Module References

None.

Sample

In the following section of example code, a Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe module is used to run a Windows PowerShell script that displays a list of PIDs and Handle counts for all svcHost.exe running processes.

<Task ID="Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbeTask" Accessibility="Public" Enabled="true" Target="Windows!Microsoft.Windows.Computer" Timeout="300">
  <Category>Custom</Category>
  <ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
    <ScriptName>Shows a list of PIDS and Handle Counts for all "svcHost" processes</ScriptName>
    <ScriptBody>
      param($ProcessName)

      # Create a new property bag
      $oAPI = new-object -comObject "MOM.ScriptAPI"
      $pb = $oAPI.CreatePropertyBag()

      get-process $ProcessName | %{$pb.AddValue($_.Id,$_.Handles)}

      $pb
    </ScriptBody>
    <Parameters>
      <Parameter>
        <Name>ProcessName</Name>
        <Value>svchost</Value>
      </Parameter>
    </Parameters>
    <TimeoutSeconds>180</TimeoutSeconds>
    <StrictErrorHandling>true</StrictErrorHandling>
  </ProbeAction>
</Task>

Information

   

Module Type

ProbeActionModuleType

Input Type

System.BaseData

Output Type

System.PropertyBagData

Implementation

Composite

Library

Microsoft.Windows.Library