Add-CMDeviceCollectionQueryMembershipRule

Adds a query membership rule to one or more Configuration Manager device collections.

Syntax

Add-CMDeviceCollectionQueryMembershipRule
   -CollectionId <String>
   [-PassThru]
   -QueryExpression <String>
   -RuleName <String>
   [-ValidateQueryHasResult]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMDeviceCollectionQueryMembershipRule
   -CollectionName <String>
   [-PassThru]
   -QueryExpression <String>
   -RuleName <String>
   [-ValidateQueryHasResult]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMDeviceCollectionQueryMembershipRule
   -InputObject <IResultObject>
   [-PassThru]
   -QueryExpression <String>
   -RuleName <String>
   [-ValidateQueryHasResult]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-CMDeviceCollectionQueryMembershipRule cmdlet adds a rule that adds devices to the collections based on a query. You can specify the device collections by names, IDs, or an object that represents the collections. The query is specified as a text string.

A query rule lets you dynamically update the members of a collection based on a query that is run on a schedule. For more information on collection rules in Configuration Manager, 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: Add a query membership rule

PS XYZ:\>Add-CMDeviceCollectionQueryMembershipRule -CollectionName "Mobile Windows 7 Devices" -QueryExpression "select SMS_R_System.ResourceId, SMS_R_System.ResourceType, SMS_R_System.Name, SMS_R_System.SMSUniqueIdentifier, SMS_R_System.ResourceDomainORWorkgroup, SMS_R_System.Client from  SMS_R_System inner join SMS_G_System_TPM on SMS_G_System_TPM.ResourceID = SMS_R_System.ResourceId" -RuleName "TPM Information"

This command adds a membership rule named TPM Information to the device collection named Mobile Windows 7 Devices. The QueryExpression parameter specifies the query that defines the membership rule.

Parameters

-CollectionId

Specifies the ID of the device collection where the rule is applied.

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

Specifies the name of the device collection where the rule is applied.

Type:String
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False
-DisableWildcardHandling

This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.

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

This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.

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

{{ Fill InputObject Description }}

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

Add this parameter to return an object that represents the item with which you're working. By default, this cmdlet may not generate any output.

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

Specifies the query expression that Configuration Manager uses to update the device collections.

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

Specifies the name for the rule.

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

{{ Fill ValidateQueryHasResult Description }}

Type:SwitchParameter
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

System.Object