Add-CMDeviceCollectionQueryMembershipRule
Add-CMDeviceCollectionQueryMembershipRule
Adds a query membership rule to one or more Configuration Manager device collections.
Syntax
Parameter Set: ByCollectionId
Add-CMDeviceCollectionQueryMembershipRule -CollectionId <String> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: ByCollectionName
Add-CMDeviceCollectionQueryMembershipRule -CollectionName <String> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: ByCollectionValue
Add-CMDeviceCollectionQueryMembershipRule -Collection <IResultObject> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed 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 using their names, IDs, or by specifying 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 Microsoft System Center 2012 Configuration Manager, see Introduction to Collections in Configuration Manager (https://go.microsoft.com/fwlink/p/?LinkID=259433) in the TechNet library.
Parameters
-Collection<IResultObject>
Specifies a Configuration Manager device collection object. To obtain a device collection object, use the Get-CMDeviceCollection cmdlet.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-CollectionId<String>
Specifies the ID of the device collection where the rule is applied.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-CollectionName<String>
Specifies the name of the device collection where the rule is applied.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-QueryExpression<String>
Specifies the query expression that Configuration Manager uses to update the device collections.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-RuleName<String>
Specifies the name for the rule.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
Examples
Example 1: Add a query membership rule
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.
PS C:\> 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"
Related topics
Get-CMDeviceCollectionQueryMembershipRule