Add-CMUserCollectionQueryMembershipRule
Add-CMUserCollectionQueryMembershipRule
Adds a query membership rule to one or more Configuration Manager user collections.
Syntax
Parameter Set: ByCollectionId
Add-CMUserCollectionQueryMembershipRule -CollectionId <String> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: ByCollectionName
Add-CMUserCollectionQueryMembershipRule -CollectionName <String> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: ByCollectionValue
Add-CMUserCollectionQueryMembershipRule -Collection <IResultObject> -QueryExpression <String> -RuleName <String> [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Add-CMUserCollectionQueryMembershipRule cmdlet adds a rule that adds users to the collections based on a query in Microsoft System Center 2012 Configuration Manager. You can specify the user 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, 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 user collection object. To obtain a user collection object, use the Get-CMUserCollection 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 user 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 user 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 user 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 rule to a collection by using a name
This command adds a rule named Remote Users by Domain to the collection named Remote Users. The command specifies the query as a string.
PS C:\> Add-CMUserCollectionQueryMembershipRule -CollectionName "Remote Users" -QueryExpression "select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User" -RuleName "Remote Users by Domain"