Edit

Share via


Remove-CMCollectionDirectMembershipRule

Remove a direct membership rule from a device or user collection.

Syntax

ByNameAndName (Default)

Remove-CMCollectionDirectMembershipRule
    -CollectionName <String>
    -ResourceName <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByNameAndValue

Remove-CMCollectionDirectMembershipRule
    -CollectionName <String>
    -Resource <IResultObject[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByNameAndId

Remove-CMCollectionDirectMembershipRule
    -CollectionName <String>
    -ResourceId <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByIdAndValue

Remove-CMCollectionDirectMembershipRule
    -CollectionId <String>
    -Resource <IResultObject[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByIdAndId

Remove-CMCollectionDirectMembershipRule
    -CollectionId <String>
    -ResourceId <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByIdAndName

Remove-CMCollectionDirectMembershipRule
    -CollectionId <String>
    -ResourceName <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByValueAndValue

Remove-CMCollectionDirectMembershipRule
    -InputObject <IResultObject>
    -Resource <IResultObject[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByValueAndId

Remove-CMCollectionDirectMembershipRule
    -InputObject <IResultObject>
    -ResourceId <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByValueAndName

Remove-CMCollectionDirectMembershipRule
    -InputObject <IResultObject>
    -ResourceName <String[]>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Use this cmdlet to remove a direct membership rule from a device or user collection. A direct membership rule lets you explicitly choose the members of the collection. Default collections don't have direct membership rules. Any collection that you target should have an ID that starts with the site code, not SMS. For more information, see How to create collections in Configuration Manager.

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

Note

Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.

Examples

Example 1: Remove the local machine from a collection of test devices

This example uses the Windows environment variable ComputerName to remove it from the collection named Test Devices. It uses the Force parameter to not prompt for confirmation.

Remove-CMCollectionDirectMembershipRule -CollectionName 'Test Devices' -ResourceName $env:ComputerName -Force

Parameters

-CollectionId

Specify the ID of the collection with the direct rule to remove. For example, "XYZ0003F".

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Id

Parameter sets

ByIdAndValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByIdAndId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByIdAndName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CollectionName

Specify the name of the collection with the direct rule to remove.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Name

Parameter sets

ByNameAndName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByNameAndValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByNameAndId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Run the command without asking for confirmation.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

Specify a collection object with the direct rule to remove. To get this object, use the Get-CMCollection, Get-CMDeviceCollection, or Get-CMUserCollection cmdlets.

Parameter properties

Type:IResultObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Collection

Parameter sets

ByValueAndValue
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
ByValueAndId
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
ByValueAndName
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Resource

Specify an array of resource objects to remove from the collection. To get this object, use the Get-CMResource, Get-CMDevice, or Get-CMUser cmdlets.

Parameter properties

Type:

IResultObject[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:Resources

Parameter sets

ByNameAndValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByIdAndValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByValueAndValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceId

Specify an array of resource IDs to remove from the collection. This value is the ResourceId property of the SMS_Resource class. For example, "33555693".

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:ResourceIds

Parameter sets

ByNameAndId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByIdAndId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByValueAndId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceName

Specify an array of resource names to remove from the collection.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:True
DontShow:False
Aliases:ResourceNames

Parameter sets

ByNameAndName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByIdAndName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByValueAndName
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet doesn't run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

System.Object

Notes

This cmdlet is similar to Remove-CMDeviceCollectionDirectMembershipRule and Remove-CMUserCollectionDirectMembershipRule, which are specific to the type of collection. This cmdlet works with either device or user collections.