Partilhar via


USMT 5 with hardlinks in the Configuration Manager 2012 OSD Task Sequence - Online and Offline

Using USMT with hardlinks within a Configuration 2012 OSD task sequence takes a moderate amount of experience. This blog entry sets out to bring you up to speed quickly using either USMT 5 hardlinks initiated from within the OS (online) or from WinPE (offline) within a Configuration Manager 2012 OSD task sequence. The following text will walk you through configuring an image deployment task sequence using USMT 5 hardlinks in both online and offline scenarios.

USMT 5 is now included in the ADK as a component. Once USMT 5 is installed as part of the ADK, the directory holding USMT's 'amd64' and 'x86' directories can be either left in place or moved elsewhere depending on preference. A Configuration Manager 2012 package should be created with this source directory (no program needed). Note that the USMT package has both 'amd64' and 'x86' subdirectories and when used within a Configuration Manager 2012 task sequence the appropriate USMT 32 or 64-bit files will be used automatically. The next quick step is to distribute your USMT package to the appropriate CM distribution point(s).

You'll of course need an OSD task sequence to configure with USMT. You'll need to create an image deployment task sequence if you don't have one available. Next, edit the image deployment task sequence to bring up the task sequence GUI.

USMT 5 hardlinks in the online scenario

To configure an image deployment task sequence with USMT 5 hardlinks in the online scenario I start by creating a group at the beginning of the task sequence which must be placed prior to any reboots into WinPE so that it is executed in the original operating system environment. Setting a condition on this group to ensure it is only run in this environment:

Task Sequence Variable _SMSTSInWinPE equals "false"

Create the following steps within the group to capture the data with hardlinks (online scenario):

- Although not absolutely necessary, adding as a first step restarting the system back into the operating system ensures no files are locked before capturing data

- Next, add a 'Set Task Sequence Variable' step and type in the variable OSDMigrateAdditionalCaptureOptions. This variable can hold any /ue or /uel USMT commands. Note that USMT 5 now executes /ue commands at a higher priority than /uel commands reversing the behavior of USMT 4. Also note that Configuration Manager 2012 has a checkbox for using hardlinks in the 'Capture User State' step so the hardlink parameters are no longer necessary in this variable.

- Next, add another 'Set Task Sequence Variable' step and type in the variable OSDStateStorePath. Based on the information in this article https://blogs.technet.com/b/configurationmgr/archive/2010/06/30/how-to-use-usmt-4-hardlinking-in-a-configuration-manager-2007-task-sequence.aspx it's best to set the user state location outside of the Configuration Manager cache directory AND on the drive running the operating system. Setting the OSDStateStorePath using the variable %systemdrive% is one way to accomplish this as shown below:
  - Set the value to %systemdrive%\UserState

- Finally, add the step 'Capture User State' to execute the capture. This step has several options:
  - Select the 'USMT 5' Configuration Manager 2012 package
  - Ensure the button 'Customize how user profiles are captured' is selected and select the .xml files that will be used (another blog post discusses this)
  - Choose 'Enable verbose logging' if desired. I typically check this.
  - Ensure the button 'Copy by using file system access' is enabled
  - Choose 'Continue if some files cannot be copied'. I typically do not check this since I would rather the USMT fail and the task sequence stop if data is missing.
  - Check 'Capture locally by using links instead of copying files' to enable hardlinks (under the hood this adds the /hardlink /nocompress parameters)
  - In this scenario, ensure the checkbox 'Capture in off-line mode' is unchecked.

If you are setting up the task sequence to handle Bitlocker partitions this can be challenging since the BitLocker partition can be on different partitions and within WinPE the drive letters don't always reflect the partition order. One way to handle this is to create a variable within WinPE to determine the drive letter that the 'User State' directory is present on which will also be the drive letter to target the operating system since the 'User State' directory was created on the drive running the operating system. I set this variable by checking each of the common drive letters for the 'User State' directory I created earlier and then setting the variable to the drive letter if the 'User State' directory exists. An example of how to do this is shown in the following steps:

- Create a group immediately after the reboot into WinPE
- Add a 'Set Task Sequence Variable' step and type in the variable OSDisk
  - Set the value to E:
-
Set the condition to folder E:\UserState exists
-
Add a 'Set Task Sequence Variable' step and type in the variable OSDisk. Note that if the 'User State' directory exists on multiple drives it will prioritize from C: to E: since E: is done first followed by D: and C:.
  - Set the value to D:
-
Set the condition to folder D:\UserState exists
-
Add a 'Set Task Sequence Variable' step and type in the variable OSDisk
-
Set the value to C :
-
Set the condition to folder C:\UserState exists

With this logic in place the variable OSDisk can be used. If you are setting up the task sequence to run a bare metal install if started within WinPE the 'Format and Partition Disk' step should also be configured to set the OSDisk variable to the proper partition.

The final step is to configure the 'Apply Operating System Image' step to apply the operating system to the drive letter in the OSDisk variable. 

- To do this set the step's Destination field to Logical drive letter stored in a variable
-
Set the variable name field to OSDisk

This concludes the configuration of the USMT hardlink capture within the OS for the online scenario. Below is the configuration of the USMT hardlink capture from within WinPE (offline). The restore configuration is the same for both the online and offline modes and will be covered last.

USMT 5 hardlinks in the offline scenario

To configure an image deployment task sequence with USMT 5 hardlinks in the offline scenario I start by creating a group at the beginning of the WinPE section of the task sequence which must be placed after the reboot into WinPE so that it is executed in the WinPE environment. I set the following condition on this group to ensure it is only run if a valid Windows directory exists to collect data. Note that in WinPE the drive letter that the valid Windows directory may exist on could depend on whether a Bitlocker partition is present OR an optical drive exists. Covering the common three cases provides needed flexibility for non-Bitlocker OS's like XP, VMs without optical drives, and physical workstations with optical drives. Add additional drives if necessary.

If Any the conditions are true:
  Folder C:\Windows exists
  Folder D:\Windows exists
  Folder E:\Windows exists

Create the following steps within the group to capture the data with hardlinks (offline scenario):

- Add three 'Set Task Sequence Variable' steps, one for each drive letter that data could exist on (C, D, or E to cover the common cases). Note it may make sense to start with drive E: and work towards C: to give C: a higher priority than E:. For each step:
  - Type in the variable OSDStateStorePath
-
Set the value of the variable to the value below. The directory name could be anything. Ex. E:\UserState
    - Set the value to <drive letter>:\UserState
-
Set the condition on the step to the value below. Ex. Folder E:\Windows exists
    - Set the condition to folder <drive letter>:\Windows exists

- Create a 2nd group to set a variable with the drive letter the OS should be installed on (or add the statements as part of the last group)
- Add a 'Set Task Sequence Variable' step and type in the variable OSDisk
-
Set the value to E:
-
Set the condition to folder E:\UserState exists
-
Add a 'Set Task Sequence Variable' step and type in the variable OSDisk.
-
Set the value to D :
-
Set the condition to folder D:\UserState exists
-
Add a 'Set Task Sequence Variable' step and type in the variable OSDisk
-
Set the value to C :
-
Set the condition to folder C:\UserState exists

- Finally, add the step 'Capture User State' to execute the capture. This step has several options:
  - Select the 'USMT 5' Configuration Manager 2012 package
  - Ensure the button 'Customize how user profiles are captured' is selected and select the .xml files that will be used (another blog post discusses this)
  - Choose 'Enable verbose logging' if desired. I typically check this.
  - Ensure the button 'Copy by using file system access' is enabled
  - Choose 'Continue if some files cannot be copied'. I typically do not check this since I would rather the USMT fail and the task sequence stop if data is missing.
  - Check 'Capture locally by using links instead of copying files' to enable hardlinks (under the hood this adds the /hardlink /nocompress parameters)
  - In this scenario, ensure the checkbox 'Capture in off-line mode' is checked.

That concludes the configuration of the offline capture group. The following additional condition needs to be added to the partition step so that the partition step will be skipped when offline USMT data is collected:

If None of the conditions are true:
  Folder C:\Windows exists
  Folder D:\Windows exists
  Folder E:\Windows exists

The final step is to configure the 'Apply Operating System Image' step to apply the operating system to the drive letter in the OSDisk variable. 

- To do this set the step's Destination field to Logical drive letter stored in a variable
-
Set the variable name field to OSDisk

This concludes the configuration of the USMT hardlink capture for the offline scenario. Next, is the configuration of the USMT hardlinks restore which is used for both online and offline scenarios.

USMT hardlinks restore

To configure an image deployment task sequence to restore USMT 5 hardlinks I start by creating a group within the OS environment after the WinPE section and the Configuration Manager client installation has completed. To ensure this group is not run if USMT has not run previously the following condition can be added if the variable has been defined in the USMT capture section:

Task Sequence Variable OSDMigrateAdditionalCaptureOptions exists

Create the following steps within the group to restore the hardlink data:

- Add a 'Set Task Sequence Variable' step and type in the variable OSDMigrateAdditionalRestoreOptions. This variable will typically hold the same /ue or /uel USMT commands that were used in the capture although I don't believe it is absolutely required. Note that USMT 5 now executes /ue commands at a higher priority than /uel commands reversing the behavior of USMT 4. Also note that Configuration Manager 2012 has a checkbox for using hardlinks in the 'Capture User State' step so the hardlink parameters are no longer necessary in this variable.

- Next, add the 'Restore User State' step. This step has several options:
  - Select the 'USMT 5' Configuration Manager 2012 package
  - Ensure the button 'Customize how user profiles are captured' is selected and select the same .xml files that were used in the capture
  - Optionally choose whether to restore local user profiles
  - Choose 'Continue if some files cannot be copied'. I typically do check this since at this point since I would not want a single error to prevent restoring all the data.
  - Choose 'Enable verbose logging' if desired. I typically check this.

Note with Configuration Manager 2012 and USMT 5 the UserState directory is removed automatically.

This concludes the configuration of the USMT hardlink restoration.

Hopefully this information is helpful and saves you time getting USMT 5 hardlinks configured in your Configuration Manager 2012 OSD task sequence.

Note: No warranty or support is implied with the use of the information discussed in this article.