Get-CMCollectionQueryMembershipRule
Get a query membership rule for a device or user collection.
Syntax
ByName (Default)
Get-CMCollectionQueryMembershipRule
-CollectionName <String>
[-RuleName <String>]
[<CommonParameters>]
ById
Get-CMCollectionQueryMembershipRule
-CollectionId <String>
[-RuleName <String>]
[<CommonParameters>]
ByValue
Get-CMCollectionQueryMembershipRule
-InputObject <IResultObject>
[-RuleName <String>]
[<CommonParameters>]
Description
Use this cmdlet to get one or more query membership rules for 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. For more information, see How to create collections in Configuration Manager.
For more information about membership rules, see Introduction to collections in Configuration Manager.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>
. For more information, see getting started.
Examples
Example 1: Get all query membership rules for the All Systems collection
This command gets the query membership rules from the default device collection named All Systems.
Get-CMCollectionQueryMembershipRule -CollectionName "All Systems"
Example 2: View the query expression for a rule on the All Users collection
This command gets the query membership rule named All Users from the All Users collection and returns the query expression.
Get-CMCollectionQueryMembershipRule -CollectionId "SMS00002" -RuleName "All Users" | Select-Object QueryExpression
Parameters
-CollectionId
Specify the ID of the collection to get the rule. This value is the CollectionID property, for example, XYZ00012
or SMS00001
.
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 get 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 |
-InputObject
Specify an object for the collection to get 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 get from the collection.
Parameter properties
Type: | String |
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 |
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 Get-CMDeviceCollectionQueryMembershipRule and Get-CMUserCollectionQueryMembershipRule, which are specific to the type of collection. This cmdlet works with either device or user collections.
Related Links
- Remove-CMCollectionQueryMembershipRule
- Get-CMCollectionDirectMembershipRule
- Get-CMCollectionExcludeMembershipRule
- Get-CMCollectionIncludeMembershipRule
- Add-CMDeviceCollectionQueryMembershipRule
- Add-CMUserCollectionQueryMembershipRule
- Get-CMDeviceCollectionQueryMembershipRule
- Get-CMUserCollectionQueryMembershipRule
- Get-CMCollection
- Get-CMDeviceCollection
- Get-CMUserCollection
- How to create collections in Configuration Manager