次の方法で共有


Using Management Pack Context Parameters in Scripts

Applies To: System Center 2012 - Operations Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Context parameters are variables that you can use in a management pack's XML file or in a custom runtime script that is added to a management pack. You can use context parameters to reference runtime data for specific objects in the management pack. For example, you can reference the globally unique identifier (GUID) of a class instance that is targeted by a rule.

Whether a context parameter is used in a management pack or in a runtime script, it must be nested between opening and closing dollar symbols ($), as shown in the following example:

$MPElement$

The following table describes the available context parameters that you can use in a management pack or in a runtime script.

Context parameter Description

$MPElement$

Provides the GUID of the monitoring object (that is, discovery, monitor, rule, or task) in which the context parameter is used.

$MPElement[Name='ElementName']$

References an element in the current management pack by name, as in the following example:

$MPElement[Name='Microsoft.Demo.Scripting.AppY']$

$MPElement[Name = 'MPAlias!ElementName']$

References an element in a referenced management pack by name, as in the following example:

$MPElement[Name='Windows!Microsoft.Windows.Computer']$

$Target/Id$

Provides the GUID of the class instance that is targeted by the current monitoring object.

$Target/ManagementGroup/Id$

Provides the GUID of the management group to which the class instance that is targeted by the current monitoring object belongs.

$Target/ManagementGroup/Name$

Provides the name of the management group to which the class instance that is targeted by the current monitoring object belongs.

$Target/Property[Type='ClassName']/PropertyName$

References a property of the class instance that is targeted by the current monitoring object. Use this syntax when the property is defined in the current management pack, as in the following example:

$Target/Property[Type='Microsoft.Demo.Scripting.AppXComponent']/FileName$

$Target/Property[Type='MPAlias!ClassName']/PropertyName$

References a property from a parent class of the target class instance. Use this syntax when the property is defined in a referenced management pack, as in the following example:

$Target/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$

$Target/Host/Property[Type='ClassName']/PropertyName$

$Target/Host/Host/…/Property[Type='ClassName']/PropertyName$

References a property of any host of the class instance that is targeted by the current monitoring object. Use this syntax when the property is defined in the current management pack. Replace the ellipsis (…) with the appropriate number of Host keywords to navigate to any instance in the hosting hierarchy, as in the following example:

$Target/Host/Property[Type='Microsoft.Demo.Scripting.AppX']/Path$

$Target/Host/Property[Type='MPAlias!ClassName']/PropertyName$

$Target/Host/Host/…/Property[Type='MPAlias!ClassName']/PropertyName$

References a property of any host of the class instance that is targeted by the current monitoring object. Use this syntax when the property is defined in a referenced management pack. Replace the ellipsis (…) with the appropriate number of Host keywords to navigate to any instance in the hosting hierarchy, as in the following example:

$Target/Host/Property[Type='Windows!Microsoft.Demo.Scripting.AppX']/Path$

$Config/XPathExpression$

References a parameter that is defined in the configuration of a monitor or module type. This is used only for defining composites. The XPath expression must be defined relative to the <Configuration> element. For example, if a Configuration element is defined as follows:

<Configuration>
  <xsd:element name="IntervalSeconds" type="xsd:integer"/>
</Configuration>

a parameter can reference the element's value as follows:

<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>

$Data/XPathExpression$

References a data item (for example, a name-value pair that is stored in a MOMPropertyBag object). The XPath expression to reference a data item depends on the item's type. The following examples show data item references that include XPath expressions:

$Data/EventDisplayNumber$

$Data/PublisherName$

$Data/Params/Param[1]$

See Also

Tasks

How to Create Discovery Data by Using a Script
How to Create Monitoring Data by Using a Script

Concepts

Getting Started Developing Runtime Scripts
Runtime Scripts Overview