In Configuration Manager, the DeleteMembershipRule Windows Management Instrumentation (WMI) class method deletes a membership rule from the collection.
The following syntax is simplified from Managed Object Format (MOF) code and is intended to show the definition of the method.
SInt32 DeleteMembershipRule( SMS_CollectionRule collectionRule );
- Data type: SMS_CollectionRuleQualifiers: [in]SMS_CollectionRule Server WMI Class object to delete.
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 following example shows how to delete both a direct rule and a query rule.
Dim instCollection As SWbemObject 'Instance of SMS_Collection Dim instQueryRule As SWbemObject 'Instance of SMS_CollectionRuleQuery Dim instDirectRule As SWbemObject 'Instance of SMS_CollectionRuleDirect Set instCollection = Services.Get("SMS_Collection.CollectionID=""<collectionid>""") ' Identify and delete the query rule. Set instQueryRule = Services.Get("SMS_CollectionRuleQuery").SpawnInstance_ instQueryRule.QueryID = <id number> instCollection.DeleteMembershipRule instQueryRule ' Identify and delete the direct rule. Set instDirectRule = Services.Get("SMS_CollectionRuleDirect").SpawnInstance_ instDirectRule.ResourceID = <resource id> instCollection.DeleteMembershipRule instDirectRule
To delete multiple rules, use DeleteMembershipRules Method in Class SMS_Collection.
For more information, see Configuration Manager Server Runtime Requirements.
For more information, see Configuration Manager Server Development Requirements.
ReferenceSMS_Collection Server WMI Class
Send comments about this topic to Microsoft.