The AddMembershipRules (WMI) class method, in System Center 2012 Configuration Manager, adds multiple new rules to the CollectionRules property of the SMS_Collection Server WMI Class object.

The following syntax is simplified from Managed Object Format (MOF) code and defines the method.

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



Data type: SMS_CollectionRule ArrayQualifiers: [in]SMS_CollectionRule Server WMI Class objects to add.

Data type: UInt32 ArrayQualifiers: [out]IDs corresponding to the rules. These are System Center 2012 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.


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.


Runtime Requirements

Development Requirements

For more information, see Configuration Manager Server Development Requirements.

See Also