ExpressionType (GroupPopulationSchema)

Applies To: Operations Manager 2007 R2

The ExpressionType (GroupPopulationSchema) complex data type defines an expression that can be evaluated to either true or false from within a MembershipRuleType definition in the context of group population filtering.

Schema Definition

<xsd:complexType name="ExpressionType">
  <xsd:choice>
    <xsd:element name="SimpleExpression" type="SimpleCriteriaType" />
    <xsd:element name="UnaryExpression" type="UnaryCriteriaType" />
    <xsd:element name="RegExExpression" type="RegExCriteriaType" />
    <xsd:element name="Contains" type="ContainsCriteriaType" />
    <xsd:element name="NotContains" type="ContainsCriteriaType" />
    <xsd:element name="Contained" type="ContainedCriteriaType" />
    <xsd:element name="NotContained" type="ContainedCriteriaType" />
    <xsd:element name="And" type="AndType" />
    <xsd:element name="Or" type="OrType" />
  </xsd:choice>
</xsd:complexType>

Remarks

The ExpressionType (GroupPopulationSchema) schema type allows for many different comparison scenarios in the context of a group population.

The basic expression types that can be combined with logical operators are described in the following table.

Expression Type Description

SimpleExpression

Evaluates two values by using a simple comparison (equal, not equal, less than, greater than, less than or equal, greater than or equal). The two values can be cast to the appropriate type for comparison.

UnaryExpression

Evaluates whether or not the value is null. Supports only two operators (IsNull, IsNotNull).

RegexExpression

Evaluates one value against a regular expression or a wildcard expression; or searches for a substring.

SimpleExpression

A SimpleExpression type compares two values (left side and right side) with a simple operator of the types described in the following table.

Operator Description

Like

Evaluates to true if the left side of the expression is not like the right side. This evaluation is case-insensitive by default.

NotLike

Evaluates to true if the left side of the expression is not like the right side. This evaluation is case-insensitive by default.

Equal

Evaluates to true if the left side of the expression is equal to the right side. This evaluation is case-insensitive by default.

NotEqual

Evaluates to true if the left side of the expression is not equal to the right side. This evaluation is case-insensitive by default.

Greater

Evaluates to true if the left side of the expression is greater in value than the right side. This is a string comparison by default.

Less

Evaluates to true if the left side of the expression is less in value than the right side. This is a string comparison by default.

GreaterEqual

Evaluates to true if the left side of the expression is greater than or equal in value to the right side. This is a string comparison by default.

LessEqual

Evaluates to true if the left side of the expression is less than or equal in value to the right side. This is a string comparison by default.

The following XML is a simple example of an expression that filters out all Windows-based computers that are not virtual machines.

<Expression>
  <SimpleExpression>
    <ValueExpression>
      <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/IsVirtualMachine$</Property>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
      <Value>False</Value>
    </ValueExpression>
  </SimpleExpression>
</Expression>

UnaryExpression

The UnaryExpression type evaluates whether or not a value expression is a null value. The operator for a unary expression can be one of the following values: IsNull or IsNotNull. The following expression returns true if the NetBios name is null; otherwise, it returns false.

<Expression>
  <UnaryExpression>
    <ValueExpression>
      <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetbiosDomainName$</Property>
    </ValueExpression>
    <Operator>IsNull</Operator>
  </UnaryExpression>
</Expression>

RegexExpression

The RegExExpression type compares a value expression (left side) to a wildcard or regular expression (right side). The value expression is specified in the same way as the simple expression. The regular expression is specified by using a pattern element.

The allowed operators for regular expression comparisons are described in the following table.

Operator Description

MatchesWildcard

The expression evaluates as true if it matches the specified wildcard expression. The following wildcard characters are allowed:

  • #—represents a number [0–9].

  • ?—represents any single character.

  • *—represents any sequence of characters.

  • \—escapes the following character; for example, \# is used to specify the # character.

ContainsSubstring

Expression evaluates as true if it contains the substring specified in the pattern. The pattern is mapped to a regular expression, such as "^.*EscapedPattern.*$".

MatchesRegularExpression

The expression evaluates as true if it matches the specified regular expression pattern. The regular expression evaluation uses the ATL regular expression engine.

DoesNotContainSubstring

The expression evaluates as true if it does not contain the substring specified in the pattern.

DoesNotMatchWildcard

The expression evaluates as true if it does not match the specified wildcard pattern.

DoesNotMatchRegularExpression

The expression evaluates as true if it does not match the specified regular expression pattern.

Note

Some Operations Manager 2005 comparison types are allowed in the operator for backward compatibility only. These should not be used for new management packs.

The following code shows an example of the use of the RegExExpression type. In this sample, a regular expression is to filter out all Windows-based computers that do not contain the pattern ‘^MicrosoftCorp’:

<Expression>
  <RegExExpression>
    <ValueExpression>
      <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetbiosDomainName$</Property>
    </ValueExpression>
    <Operator>MatchesRegularExpression</Operator>
    <Pattern>^MicrosoftCorp</Pattern>
  </RegExExpression>
</Expression>

Contains, NotContains, Contained, Contained

The containment expressions Contained, NotContained, Contains, and NotContains allow you to provide a filter based on the hosting relationships of the monitoring class. The Contains and NotContains expressions allow you to provide a filter based on the class types that the monitoring class might or might not contain. The Contained and NotContained expressions allow you provide a filter based on the class types that contain or do not contain the monitoring class.

The following code illustrates a Contains expression. A Microsoft.SystemCenter.Agent class type is defined as being contained by a Microsoft.SystemCenter.ManagedComputer instance. Not all managed computers contain agents, but in this sample, the group filter wants to include only those managed computers that contain an agent.

<MembershipRule>
  <MonitoringClass>$MPElement[Name="SCLibrary!Microsoft.SystemCenter.ManagedComputer"]$</MonitoringClass>
  <RelationshipClass>$MPElement[Name="SCLibrary!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$</RelationshipClass>
  <Expression>
    <Contains>
      <MonitoringClass>$MPElement[Name="SCLibrary!Microsoft.SystemCenter.Agent"]$</MonitoringClass>
    </Contains>
  </Expression>
</MembershipRule>

The RegExExpression, SimpleExpression, and UnaryExpression elements can be combined to form multiple comparisons.

Operator Element Description

And

Combines two or more expressions with a logical AND. All expressions contained in the And element must evaluate to true for the overall expression to evaluate to true; otherwise, the result is false.

Or

Combines two or more expressions with a logical OR. At least one expression contained in the Or element must evaluate to true for the overall expression to evaluate to true; otherwise, the result is false.

Multiple expression types are represented in the XML configuration with the operator as the element and then one or more expressions contained as sub-elements.

The following example shows how to combine two expressions in an AND operation:

<Expression>
      <And>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/IsVirtualMachine$</Property>
            </ValueExpression>
            <Operator>Equal</Operator>
            <ValueExpression>
              <Value>False</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetBiosDomainName$</Property>
            </ValueExpression>
            <Operator>Like</Operator>
            <ValueExpression>
              <Value>Red</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
      </And>
</Expression>

There is no limit to how many expressions can be combined with a single operator. Multiple operators can be combined as required.

The following code example shows an AND expression contained within an OR expression:

<Expression>
  <Or>
    <Expression>
      <And>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/IsVirtualMachine$</Property>
            </ValueExpression>
            <Operator>Equal</Operator>
            <ValueExpression>
              <Value>False</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetBiosDomainName$</Property>
            </ValueExpression>
            <Operator>Like</Operator>
            <ValueExpression>
              <Value>Red</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
      </And>
    </Expression>
    <Expression>
      <And>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetBiosDomainName$</Property>
            </ValueExpression>
            <Operator> Like </Operator>
            <ValueExpression>
              <Value Type="String">Blue</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/IsVirtualMachine$</Property>
            </ValueExpression>
            <Operator>Equal</Operator>
            <ValueExpression>
              <Value>True</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
      </And>
    </Expression>
  </Or>
</Expression>

Information

   

Schema Type

Microsoft.SystemCenter.GroupPopulationSchema

Library

Microsoft.SystemCenter.Library