Add-CMUserAffinityToDevice

Add-CMUserAffinityToDevice

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

Syntax

Parameter Set: AddUserAffinityByDeviceName
Add-CMUserAffinityToDevice -DeviceName <String[]> [-UserId <String> ] [-UserName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: AddUserAffinityByDeviceId
Add-CMUserAffinityToDevice -DeviceId <String[]> [-UserId <String> ] [-UserName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

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

Parameters

-DeviceId<String[]>

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

Aliases

ResourceId

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DeviceName<String[]>

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

Aliases

ResourceName

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-UserId<String>

Specifies the ID of a user.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-UserName<String>

Specifies the name of the primary user.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Add a primary user to a device

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

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

Remove-CMUserAffinityFromDevice