Remove-CMCollectionQueryMembershipRule
Remove a query membership rule from a device or user collection.
Syntax
ByValue (Default)
Remove-CMCollectionQueryMembershipRule
-InputObject <IResultObject>
-RuleName <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByName
Remove-CMCollectionQueryMembershipRule
-CollectionName <String>
-RuleName <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ById
Remove-CMCollectionQueryMembershipRule
-CollectionId <String>
-RuleName <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Use this cmdlet to remove a query membership rule from a device or user 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 resources.
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-CMCollectionQueryMembershipRule -CollectionName "Windows 10 devices" -RuleName "TPM" -Force
Parameters
-CollectionId
Specify the ID of the 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
.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Id |
Parameter sets
ById
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-CollectionName
Specify the name of the collection to remove the rule.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Name |
Parameter sets
ByName
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Force
Run the command without asking for confirmation.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-InputObject
Specify an object for the collection to remove the rule. To get this object, use the Get-CMCollection, Get-CMDeviceCollection, or Get-CMUserCollection cmdlets.
Parameter properties
Type: | IResultObject |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Collection |
Parameter sets
ByValue
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-RuleName
Specify the name of the query rule to remove from the collection.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
Microsoft.ConfigurationManagement.ManagementProvider.IResultObject
Outputs
System.Object
Notes
This cmdlet is similar to Remove-CMDeviceCollectionQueryMembershipRule and Remove-CMUserCollectionQueryMembershipRule, which are specific to the type of collection. This cmdlet works with either device or user collections.
Related Links
- Get-CMCollectionQueryMembershipRule
- Remove-CMCollectionDirectMembershipRule
- Remove-CMCollectionExcludeMembershipRule
- Remove-CMCollectionIncludeMembershipRule
- Add-CMDeviceCollectionQueryMembershipRule
- Add-CMUserCollectionQueryMembershipRule
- Get-CMDeviceCollectionQueryMembershipRule
- Get-CMUserCollectionQueryMembershipRule
- Get-CMCollection
- Get-CMDeviceCollection
- Get-CMUserCollection
- How to create collections in Configuration Manager