DeleteMembershipRule Method in Class SMS_Collection

The DeleteMembershipRule WMI class instance method deletes a rule from the collection.

The following syntax is simplified from MOF code and is intended to show you the definition of the method.

sint32 DeleteMembershipRule(
  [in] SMS_CollectionRule collectionRule
);

Parameters

  • collectionRule
    Data type: SMS_CollectionRule
    Qualifiers: In

    A direct rule (SMS_CollectionRuleDirect) or query rule (SMS_CollectionRuleQuery) instance. For a query rule, you must set QueryID to match the rule to delete. For a direct rule, you must specify the resource identifier.

Return Values

The DeleteMembershipRule 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 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

Remarks

To delete multiple rules, use the DeleteMembershipRules Method in Class SMS_Collection.

See Also

AddMembershipRule Method in Class SMS_Collection, DeleteMembershipRules Method in Class SMS_Collection, SMS_Collection, SMS_CollectionRuleDirect, SMS_CollectionRuleQuery