Different methods to set the User Device Affinity for usage during and after a task sequence in ConfigMgr 2012

Last week I’ve got a question about setting the User Device Affinity (UDA) during the task sequence. Well, actually the question was more about the easiest way to do this. I didn’t have a direct answer, as it’s of course also a relative question. The easiest way can be different depending on the current configuration. In this post I will go through three methods that can be used to set the UDA, so it can be used during and after the task sequence. For usage during the task sequence, think about something like installing user-targeted applications during the task sequence and for usage after the task sequence, think about the pre-deploy software to the user’s primary device option.

Before using the first, or the second method, there are a couple of prerequisites that need to be in place, like setting the task sequence variable SMSTSAssignUsersMode to Auto and configuring Allow user device affinity with automatic approval in the PXE configuration. For all the prerequisites for configuring UDA during a task sequence, see: http://technet.microsoft.com/en-us/library/hh846243.aspx

Method 1: Create an empty task sequence variable

Setting_SMSTSUdaUser_CollectionThe first method is probably the easiest method in the most situations. Also, it might remind everyone of an often used method to simply provide an input for a computer name, when using unknown computers. The nice thing is that this exact same method can be used to provide the UDA information.

Simply create a collection variable named SMSTSUdaUsers and leave the value blank. This will cause the task sequence to request input for that specific variable. Set the value to <domain>\<user> and the task sequence will configure the specified user as the primary user for the device.

Method 2: Enable prestart command

Setting_SMSTSUdaUser_PrestartThe second method is pretty similar to the first method, in a way that it will also generate an input request. This method requires some custom scripting to create an input form that request for an user name. That input form can be started as a prestart command on the boot image. To configure a prestart command, simply go to the Customization –tab of the boot image and select Enable prestart command. In case of a PowerShell script, use a command like PowerShell.exe -ExecutionPolicy ByPass .\<script>.ps1 and select Include file for the prestart command to add the script to the boot image.

To create a form, like my example, in PowerShell that requests for input, make sure to use at least a small function, like the following, that creates a task sequence variable named SMSTSUdaUsers with the value from the input field.

function Set-SMSTSUdaUsers { param( [string]$UserName ) $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment $TSEnv.Value("SMSTSUdaUsers") = $UserName }

Note: To use a PowerShell script in the boot image make sure that the Optional Component of Windows PowerShell is added. This also includes Microsoft .NET.

Method 3: Import computer information and set primary user

Setting_SMSTSUdaUser_ImportThe third method is actually just a more advanced method to Import Computer Information. A bit more then a year ago, I created a small form that allows somebody to import computer information and to also directly configure a primary user. This makes sure that a computer directly has a primary user configured, which can be used during and after a task sequence. For some more information, see: https://petervanderwoude.nl/post/updated-import-computer-form-v0-8-directly-adding-a-user-device-affinity-in-configmgr-2012/

Conclusion

There are many methods to configure the UDA for usage during and after a task sequence. Probably, there a more methods then the three mentioned in this post, but these are the most common and easy to use. Also, I didn’t mention the methods in which a users is allowed to configure it themselves, or in which an administrator can manually configure it via the console. I like automation and as less as possible manual actions. For all the different options to configure UDA via console options, see: http://technet.microsoft.com/en-us/library/gg699365.aspx

6 thoughts on “Different methods to set the User Device Affinity for usage during and after a task sequence in ConfigMgr 2012”

  1. Hi Peter,

    Is method 1 still working for the latest version of SCCM? I tried it doesn’t prompt the for a value during OS deployment

    Reply
  2. It seems like not including this as part of the state migration is a real missed opportunity. SCCM knows the primary user of the source PC. It would be nice if the Task Sequence included a step to look that up based on the device association and create it for the target PC during a state restore. Maybe something worth scripting…

    Reply
  3. Hello,

    I was wondering if there are any other steps needed to add a primary user during an image? We have set the PXE server to “Allow user device affinity with automatic approval”, and have set the task sequence variables “SMSTSAssignUsersMode” to Auto and “SMSTSUdaUsers” to the desired AD account as outlined in Method #1 (“Set the value to \ and the task sequence will configure the specified user as the primary user for the device.”). However, even after checking the task sequence mid-flight to make sure both variables are set correctly, the primary user remains blank at the end of the process. We have tried adding the variables as collection variables and have also defined them in the task sequence itself without success. Are there any other steps we’re missing? Thanks very much for your time.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.