Bewerken

Delen via


Add-CMUserAffinityToDevice

Adds a primary user to one or more devices in the Configuration Manager hierarchy.

Syntax

Add-CMUserAffinityToDevice
   -DeviceName <String[]>
   [-UserId <Int32[]>]
   [-UserName <String[]>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-CMUserAffinityToDevice
   -DeviceId <Int32[]>
   [-UserId <Int32[]>]
   [-UserName <String[]>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-CMUserAffinityToDevice cmdlet associates the devices with a primary user in Configuration Manager. You can specify the devices to associate with the primary user by their names or IDs. You can specify the primary user by their name or ID.

User device affinity is a method of associating a user with one or more specified devices. This allows you to deploy applications to a user without the requirement to know the name of all the user's devices. Instead of deploying the application to all the devices of a user, you deploy the application to the user and the application automatically installs on all devices that are associated with that user.

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 primary user to a device

PS XYZ:\>Add-CMUserAffinityToDevice -DeviceName "CMCEN-DIST-02" -UserId "2063597981"

This command adds the primary user that has the ID 2063597981 to the device named CMCEN-DIST-02.

Parameters

-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

-DeviceId

Specifies an array of IDs of the devices that you want to associate with the primary user.

Type:Int32[]
Aliases:ResourceId
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DeviceName

Specifies an array of names of the devices that you want to associate with the primary user.

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

-DisableWildcardHandling

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

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

-ForceWildcardHandling

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

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

-UserId

Specifies the ID of a user.

Type:Int32[]
Aliases:UserIds
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UserName

Specifies the name of the primary user.

Type:String[]
Aliases:UserNames
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

None

Outputs

System.Object