Edit

Share via


Add-CMDeviceCollectionDirectMembershipRule

Add a direct membership rule to a device collection.

Syntax

ByCollectionIdAndResourceId (Default)

Add-CMDeviceCollectionDirectMembershipRule
    -CollectionId <String>
    -ResourceId <Int32[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByCollectionIdAndResourceValue

Add-CMDeviceCollectionDirectMembershipRule
    -CollectionId <String>
    -Resource <IResultObject[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByCollectionNameAndResourceId

Add-CMDeviceCollectionDirectMembershipRule
    -CollectionName <String>
    -ResourceId <Int32[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByCollectionNameAndResourceValue

Add-CMDeviceCollectionDirectMembershipRule
    -CollectionName <String>
    -Resource <IResultObject[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByCollectionValueAndResourceId

Add-CMDeviceCollectionDirectMembershipRule
    -InputObject <IResultObject>
    -ResourceId <Int32[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByCollectionValueAndResourceValue

Add-CMDeviceCollectionDirectMembershipRule
    -InputObject <IResultObject>
    -Resource <IResultObject[]>
    [-PassThru]
    [-DisableWildcardHandling]
    [-ForceWildcardHandling]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Use this cmdlet to add a direct membership rule to a device collection. A direct membership rule lets you explicitly choose the members of the device collection. 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. 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 a direct membership rule

This command adds a direct membership rule to the device collection with ID XYZ00056. It adds the resource with ID 16777219 to the collection.

Add-CMDeviceCollectionDirectMembershipRule -CollectionId "XYZ00056" -ResourceId 16777219

Example 2: Add a direct membership rule by using the pipeline

This command first uses the Get-CMCollection cmdlet to get the collection object named testCollection. It then uses the pipeline operator to pass the object to the Add-CMDeviceCollectionDirectMembershipRule cmdlet, which adds the direct membership rule to the device collection object. It adds the device with ID 16777219 to the collection.

Get-CMCollection -Name "testCollection" | Add-CMDeviceCollectionDirectMembershipRule -ResourceId 16777219

Parameters

-CollectionId

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

Parameter properties

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

Parameter sets

ByCollectionIdAndResourceId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionIdAndResourceValue
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 device collection to add the rule.

Parameter properties

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

Parameter sets

ByCollectionNameAndResourceId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionNameAndResourceValue
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:False
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

-DisableWildcardHandling

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

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

-ForceWildcardHandling

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

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 an object for the device collection to add the rule. To get this object, use the Get-CMCollection or Get-CMDeviceCollection cmdlets.

Parameter properties

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

Parameter sets

ByCollectionValueAndResourceId
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionValueAndResourceValue
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments: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.

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

-Resource

Specify an array of resource objects to add to the device collection with this direct membership rule. To get this object, use the Get-CMResource cmdlet, or the Get-CMDevice cmdlet with the -Resource parameter.

Parameter properties

Type:

IResultObject[]

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

Parameter sets

ByCollectionIdAndResourceValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionNameAndResourceValue
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionValueAndResourceValue
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 IDs of the resources to add to the device collection with this direct membership rule. This value is the ResourceID property, for example 16777219.

Parameter properties

Type:

Int32[]

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

Parameter sets

ByCollectionIdAndResourceId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionNameAndResourceId
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
ByCollectionValueAndResourceId
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:False
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