DeleteMembershipRules Method in Class SMS_Collection
The DeleteMembershipRules WMI class instance method deletes rules from the collection.
The following syntax is simplified from MOF code and is intended to show you the definition of the method.
sint32 DeleteMembershipRules(
[in] SMS_CollectionRule collectionRules[]
);
Parameters
collectionRules
Data type: SMS_CollectionRule[]
Qualifiers: InAny combination of one or more direct rules (SMS_CollectionRuleDirect) and query rules (SMS_CollectionRuleQuery). For query rules, you must set QueryID to match the rule to delete. For direct rules, you must specify the resource identifier.
Return Values
The DeleteMembershipRules method returns a sint32 with a value of zero (0) when the method successfully completes.
Example Code
The following example shows you how to delete one or more collection rules.
Dim instCollection As SWbemObject 'Instance of SMS_Collection Dim instQueryRule As SWbemObject 'Instance of SMS_CollectionRuleQuery Dim instDirectRule As SWbemObject 'Instance of SMS_CollectionRuleDirect Dim Rules() As Variant 'Array of rules for DeleteMembershipRules Dim i As Integer Set instCollection = Services.Get("SMS_Collection.CollectionID=""<collectionid>""") ReDim Rules(1) '(0 to 1) array must contain exact number of objects i = 0 'Identify the query rule. Set instQueryRule = Services.Get("SMS_CollectionRuleQuery").SpawnInstance_ instQueryRule.QueryID = <queryid> Set Rules(i) = instQueryRule i = i + 1 'Identify the direct rule. Set instDirectRule = Services.Get("SMS_CollectionRuleDirect").SpawnInstance_ instDirectRule.ResourceID = <resourceid> Set Rules(i) = instDirectRule 'Delete the rules from the collection. instCollection.DeleteMembershipRules Rules
See Also
AddMembershipRules Method in Class SMS_Collection, DeleteMembershipRule Method in Class SMS_Collection, SMS_Collection, SMS_CollectionRuleDirect, SMS_CollectionRuleQuery