Add-​CM​User​Affinity​To​Device

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

Syntax

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

Description

The Add-CMUserAffinityToDevice cmdlet associates the devices with a primary user in Microsoft System Center 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.

Examples

Example 1: Add a primary user to a device

PS C:\>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.

Required Parameters

-DeviceId

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

Type:String[]
Aliases:ResourceId
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-DisableWildcardHandling

DisableWildcardHandling treats wildcard characters as literal character values. Cannot be combined with ForceWildcardHandling.

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

ForceWildcardHandling processes wildcard characters and may lead to unexpected behavior (not recommended). Cannot be combined with DisableWildcardHandling.

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

Specifies the ID of a user.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-UserName

Specifies the name of the primary user.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False