In Configuration Manager, the DeleteMembershipRules Windows Management Instrumentation (WMI) class method is used to delete more than one 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 DeleteMembershipRules(
	SMS_CollectionRule collectionRules[]
)

Parameters

collectionRules


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

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.

Example Code

The following example shows how to delete one or more collection rules.

  Copy Code
	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

Requirements

Runtime Requirements

Development Requirements

See Also


Send comments about this topic to Microsoft.