共用方式為


AddMembershipRules Method in Class SMS_Collection

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

In Configuration Manager, the AddMembershipRules (WMI) class method adds more than one new rule to the CollectionRules property of the SMS_Collection Server WMI Class object.

The following syntax is simplified from

Managed Object Format (MOF) code and is intended to show the definition of the method.

SInt32 AddMembershipRules(
     SMS_CollectionRule collectionRules[],
     UInt32 QueryIDs[]
);

Parameters

  • QueryIDs
    Data type: UInt32 Array

    Qualifiers: [out]

    IDs corresponding to the rules. These are Configuration Manager-generated query IDs for query rules. The IDs for direct rules are set to 0. Use QueryID to modify or delete a query membership rule.

Return Values

An SInt32 data type that is 0 to indicate success or non-zero to indicate failure.

For information about handling returned errors, see About Configuration Manager Errors.

Remarks

The AddMembershipRules method does not validate a query rule, but simply adds it to the rules list. This can create debugging issues when the collection does not contain the intended membership. Your application should always validate the query rule before adding it to the collection rules by using the ValidateQuery Method in Class SMS_CollectionRuleQuery.

The AddMembershipRules method can also be used to modify membership rules. Only query rules can be modified.

Example Code

For an example that adds a direct rule and a query rule to a collection, see About Configuration Manager Collections.

Requirements

Runtime Requirements

For more information, see Configuration Manager Server Runtime Requirements.

Development Requirements

For more information, see Configuration Manager Server Development Requirements.

See Also

Reference

SMS_Collection Server WMI Class

Concepts

How to Create a Subcollection
How to Create a Static Collection
How to Create a Dynamic Collection