Computer and Instance Group Fragments in VSAE

I’m updating my Technet posts about creating groups in the R2 Authoring Console. Here are the same examples using the Visual Studio Authoring Extensions. You can add these as templates to your fragment library for use in future development projects.

 

How to create a computer group using VSAE

 

Original post: How to create a computer group in the R2 Authoring Console

 

The main thing to focus on here is $MPElement[Name="YourMp.Class.YourClass"]$. This is referencing the class in which you want to include it’s hosting Windows Computer object.

 

<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <TypeDefinitions>
    <EntityTypes>
      <ClassTypes>
        <ClassType ID="YourMp.Class.YourComputerGroup" Abstract="false" Accessibility="Public" Base="SC!Microsoft.SystemCenter.ComputerGroup" Hosted="false" Singleton="true" />
      </ClassTypes>
    </EntityTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="YourMp.Discovery.YourComputerGroup" ConfirmDelivery="false" Enabled="true" Priority="Normal" Remotable="true" Target="YourMp.Class.YourComputerGroup">
        <Category>Discovery</Category>
        <DiscoveryTypes />
        <DataSource ID="DS1" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="YourMp.Class.YourComputerGroup"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$</RelationshipClass>
              <Expression>
                <Contains>
                  <MonitoringClass>$MPElement[Name="YourMp.Class.YourClass"]$</MonitoringClass>
                </Contains>
              </Expression>
            </MembershipRule>
          </MembershipRules>
        </DataSource>
      </Discovery>
    </Discoveries>
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="YourMp.Class.YourComputerGroup">
          <Name>Your Computer Group</Name>
          <Description>This group contains instances of Windows Computer objects that host YourClass.</Description>
        </DisplayString>
        <DisplayString ElementID="YourMp.Discovery.YourComputerGroup">
          <Name>Your Group Discovery</Name>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPackFragment>

 

How to create an instance group using VSAE

 

Original post: How to create an instance group in the R2 Authoring Console

 

The main thing to focus on here is $MPElement[Name="YourMp.Class.YourFirstClass"]$. This is referencing the discovered instances in which you want to include in your group. You can add multiple classes if you need the group to contain different types of instances.

 

<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <TypeDefinitions>
    <EntityTypes>
      <ClassTypes>
        <ClassType ID="YourMp.Class.YourInstanceGroup" Abstract="false" Accessibility="Public" Base="MSIL!Microsoft.SystemCenter.InstanceGroup" Hosted="false" Singleton="true" />
      </ClassTypes>
    </EntityTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="YourMp.Discovery.YourInstanceGroup" ConfirmDelivery="false" Enabled="true" Priority="Normal" Remotable="true" Target="YourMp.Class.YourInstanceGroup">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="YourMp.Class.YourFirstClass" />
          <DiscoveryClass TypeID="YourMp.Class.YourSecondClass" />
        </DiscoveryTypes>
        <DataSource ID="DS1" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="YourMp.Class.YourInstanceGroup"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="YourMp.Class.YourFirstClass"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MSIL!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
            </MembershipRule>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="YourMp.Class.YourSecondClass"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MSIL!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
            </MembershipRule>
          </MembershipRules>
        </DataSource>
      </Discovery>
    </Discoveries>
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="YourMp.Class.YourInstanceGroup">
          <Name>Your Instances Group</Name>
          <Description>This group contains all discovered instances referenced in the MonitoringClass(es).</Description>
        </DisplayString>
        <DisplayString ElementID="YourMp.Discovery.YourInstanceGroup">
          <Name>Your Instance Group Discovery</Name>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPackFragment>

 

How to create a group of Windows Computer instances that host some class and matches a property of that class.

 

Original post: How to create a group of Windows Computers based on a discovered property of virtually any class

 

The main thing to focus on here is $MPElement[Name="YourMp.Class.SomeClass"]$. This is referencing the Windows Computer hosted instances in which you want to include in your group. Also notice SomeProperty and SomePattern – this is the property you will be comparing in your regular expression.

 

<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <TypeDefinitions>
    <EntityTypes>
      <ClassTypes>
        <ClassType ID="YourMp.Class.YourComputerGroup" Abstract="false" Accessibility="Public" Base="SC!Microsoft.SystemCenter.ComputerGroup" Hosted="false" Singleton="true" />
      </ClassTypes>
    </EntityTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="YourMp.Discovery.YourComputerGroup" ConfirmDelivery="false" Enabled="true" Priority="Normal" Remotable="true" Target="YourMp.Class.YourComputerGroup">
        <Category>Discovery</Category>
        <DiscoveryTypes />
        <DataSource ID="DS1" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="YourMp.Class.YourComputerGroup"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$</RelationshipClass>
              <Expression>
                <Contains>
                  <MonitoringClass>$MPElement[Name="SomeMp.Class.SomeClass"]$</MonitoringClass>
                  <Expression>
                    <RegExExpression>
                      <ValueExpression>
                        <Property>$MPElement[Name="SomeMp.Class.SomeClass"]/SomeProperty$</Property>
                      </ValueExpression>
                      <Operator>MatchesRegularExpression</Operator>
                      <Pattern>SomePattern</Pattern>
                    </RegExExpression>
                  </Expression>
                </Contains>
              </Expression>
            </MembershipRule>
          </MembershipRules>
        </DataSource>
      </Discovery>
    </Discoveries>
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="YourMp.Class.YourComputerGroup">
          <Name>Your Computer Group</Name>
          <Description>This group contains Windows Computer instances that host some class and matches some property of that class.</Description>
        </DisplayString>
        <DisplayString ElementID="YourMp.Discovery.YourComputerGroup">
          <Name>Your Group Discovery</Name>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPackFragment>

 

Check out this other post about adding Health Service objects to a group.

 

Need help developing a management pack? Drop us a line

SCOMskills_Signature.

 

 

_

One thought on “Computer and Instance Group Fragments in VSAE”

Comments welcome (links require moderation)