Redigera

Dela via


Add-CMUserCollectionExcludeMembershipRule

Add an exclude membership rule to a user collection.

Syntax

Add-CMUserCollectionExcludeMembershipRule
   -CollectionName <String>
   -ExcludeCollectionName <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -CollectionName <String>
   -ExcludeCollection <IResultObject>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -CollectionName <String>
   -ExcludeCollectionId <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -CollectionId <String>
   -ExcludeCollection <IResultObject>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -CollectionId <String>
   -ExcludeCollectionId <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -CollectionId <String>
   -ExcludeCollectionName <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -InputObject <IResultObject>
   -ExcludeCollection <IResultObject>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -InputObject <IResultObject>
   -ExcludeCollectionId <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserCollectionExcludeMembershipRule
   -InputObject <IResultObject>
   -ExcludeCollectionName <String>
   [-PassThru]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Use this cmdlet to add an exclude membership rule to a user collection. An exclude membership rule excludes the members of another collection from the user collections where the rule is applied.

You can't add membership rules to default collections. Any collection that you target should have an ID that starts with the site code, not SMS. You can exclude a default collection, so the ID of an excluded collection can start with SMS.

Configuration Manager dynamically updates the membership of the user collection on a schedule if the membership of the excluded collection changes.

When you add an exclude membership rule to a collection, a resource may no longer be a member of the user collection. This action can cause any software or configuration deployment to not apply to a user.

For more information, see How to create 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 an exclude collection rule to a user collection

This command excludes the members of the Remote Users collection, which has the ID XYZ00017, from the user collection with ID XYZ00012.

Add-CMUserCollectionExcludeMembershipRule -CollectionId "XYZ00012" -ExcludeCollectionId "XYZ00017"

Parameters

-CollectionId

Specify the ID of the user collection to add the rule. This value is the CollectionID property, for example, XYZ00012. Since default collections don't have exclude membership rules, this ID starts with the site code and not SMS.

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 user collection to add the rule.

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

-ExcludeCollection

Specify an object for the excluded collection to add the rule. To get this object, use the Get-CMCollection or Get-CMUserCollection cmdlets.

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

-ExcludeCollectionId

Specify the ID of the excluded collection to add the rule. This value is the CollectionID property, for example, XYZ00012. You can exclude default collections, so this value can start with either the site code or SMS.

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

-ExcludeCollectionName

Specify the name of the excluded collection to add the rule.

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

-InputObject

Specify an object for the user collection to add the rule. To get this object, use the Get-CMCollection or Get-CMUserCollection cmdlets.

Type:IResultObject
Aliases:Collection
Position:Named
Default value:None
Required:True
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
Required:False
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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

System.Object