Get-CMDeviceCollectionQueryMembershipRule

Get a query membership rule for a device collection.

Syntax

Get-CMDeviceCollectionQueryMembershipRule
   -CollectionName <String>
   [-RuleName <String>]
   [<CommonParameters>]
Get-CMDeviceCollectionQueryMembershipRule
   -CollectionId <String>
   [-RuleName <String>]
   [<CommonParameters>]
Get-CMDeviceCollectionQueryMembershipRule
   -InputObject <IResultObject>
   [-RuleName <String>]
   [<CommonParameters>]

Description

Use this cmdlet to get one or more query membership rules for 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. 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-CMDeviceCollectionQueryMembershipRule -CollectionName "All Systems"

Example 2: View the query expression for a rule on the All Systems collection

This command gets the query membership rule named All Systems from the All Systems collection and returns the query expression.

Get-CMDeviceCollectionQueryMembershipRule -CollectionId "SMS00001" -RuleName "All Systems" | Select-Object QueryExpression

Parameters

-CollectionId

Specify the ID of the device collection to get the rule. This value is the CollectionID property, for example, XYZ00012 or SMS00001.

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 get the rule.

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

-InputObject

Specify an object for the device collection to get 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 get from the collection.

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

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

System.Object