Remove-CMDeviceCollectionQueryMembershipRule

Remove a query membership rule from a device collection.

Syntax

Remove-CMDeviceCollectionQueryMembershipRule
      -InputObject <IResultObject>
      -RuleName <String>
      [-Force]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-CMDeviceCollectionQueryMembershipRule
      -CollectionName <String>
      -RuleName <String>
      [-Force]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-CMDeviceCollectionQueryMembershipRule
      -CollectionId <String>
      -RuleName <String>
      [-Force]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Use this cmdlet to remove a query membership rule from a device collection. A query rule lets you dynamically update the membership of a collection based on a query that is run on a schedule. You can't remove query rules from the default collections. Any collection that you target should have an ID that starts with the site code, not SMS. For more information, see How to create collections in Configuration Manager.

When you remove a query membership rule from a collection, multiple resources may no longer be members of the collection. This action can cause any software or configuration deployment to not apply to the devices.

Note

Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.

Examples

Example 1: Remove the query membership rules for a device collection

This command removes the query membership rule named TPM from the device collection named Windows 10 devices.

Remove-CMDeviceCollectionQueryMembershipRule -CollectionName "Windows 10 devices" -RuleName "TPM" -Force

Parameters

-CollectionId

Specify the ID of the device collection to remove the rule. This value is the CollectionID property, for example, XYZ00012. Since you can't remove the query rules from default collections, this ID starts with the site code and not SMS.

Type:String
Aliases:Id
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-CollectionName

Specify the name of the device collection to remove the rule.

Type:String
Aliases:Name
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Run the command without asking for confirmation.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Specify an object for the device collection to remove the rule. To get this object, use the Get-CMCollection or Get-CMDeviceCollection cmdlets.

Type:IResultObject
Aliases:Collection
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-RuleName

Specify the name of the query rule to remove from the collection.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet doesn't run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

System.Object