Add-CMDeviceAffinityToUser

Adds device affinity to a Configuration Manager user.

Syntax

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

Description

The Add-CMDeviceAffinityToUser cmdlet adds device affinity to a user of Configuration Manager.

Device affinity in Configuration Manager associates a user with one or more devices. Instead of deploying applications to all the user's devices, you deploy the application to the user and Configuration Manager automatically installs the application on all devices that are associated with that user. Device affinity removes the need for Configuration Manager to determine the names of the devices of a user before you deploy applications for that user.

For more information, see Link users and devices with user device affinity.

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 device affinity to a user by user ID

PS XYZ:\>Add-CMDeviceAffinityToUser -UserName "Patti Fuller" -DeviceName "WestDivUpdates05"

This command adds affinity to the device named WestDivUpdates05 for the user named Patti Fuller.

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 a device by using an ID.

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

-DeviceName

Specifies a device by using a name.

Type:String[]
Aliases:DeviceNames
Position:Named
Default value:None
Required:False
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 a user by using an ID.

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

-UserName

Specifies an array of user names to associate with the device.

Type:String[]
Aliases:UniqueUserName
Position:Named
Default value:None
Required:True
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