ConfigMgr

User State

Topics: ConfigMgr

Task Sequence Steps – User State

This post is part of our Task Sequence – Beyond the Docs series.

These four steps go together, and it’s difficult to work with one without the others. Demos will require all four working together, so I’m going to merge these four into a single page, which will get long.

Requirements for CM Backup: State Migration Point. MS Docs
USMT Info: MS Docs


Request State Store

This step will reach out to your ConfigMgr Environment, request a location to capture the user data to.
MS Docs

Variables

PowerShell


Capture User State

This is the step that does the heavy lifting, it downloads the USMT Package, then runs the command to grab the items specified in the xml.

MS Docs

Variables

PowerShell


Restore User State

This is the step that restores the data you captured earlier.

MS Docs

Variables

PowerShell


Release State Store

MS Docs

Variables

PowerShell


LogFiles

There are several logs to use to follow the process of USMT, the overall would be the SMSTS.log file, but while the SMSTS.log sits on one line “Executing command line…. scanstate.exe / loadstate.exe….” there are several things going on behind the scenes, so you’d look for the appropriate log. The log will be in the SMSTSLOG subfolder while the TS is running or merged in after. More info on MS Docs

  • SMSTS.log
  • scanstate.log
  • scanstateprogress.log
  • loadstate.log
  • loadstateprogress.log

State Migration Point

UserState 1
UserState 2

Demos

Demo – Standard Setup, Defaults, Same Computer (Wipe & Load)

Here is what MS creates when you build a TS using the wizard:


UserState 4

And here it is in action:


UserState 3

You can see that it executes the scanstate.exe with a custom command line.
Then below you’ll see it restoring the data after the machine was reimaged (Wipe and Load)


UserState 5

Request State Store:


UserState 9

Capture User State:


UserState 7
UserState 10

Here the step initiates the download of the USMT Package, builds the scanstate commandline based on the variables (based on the options in the steps), makes the connection to server based on the request state store information, and triggers the user state backup to the server.

Release State Store:


UserState 11
UserState 12

This step removes the connection to the server

Variables used in TS, the store path gets wiped after you release the state store.


UserState 6

On the Server:


UserState 13
UserState 14

The Console shows that it both Backed up and Restored (Migration Status). Provides vital information about the user backup. Going to the path, you can see it created a USMT.MIG file.

Demo – Leveraging OSDMigrateAdditionalCaptureOptions Variable

In this demo, I’m adding some command line syntax, while this example doesn’t make logical sense, as I’ll explain, it’s just an example.

  • /uel:30 = Only Capture Profiles that have been active in the past 30 days
  • /ue *\* /ui:viamonstra\recast = exclude all user accounts EXCEPT the recast account in the viamonstra domain.
  • Additonal info for the command line syntax on MS Docs

Since I’m specifically telling the scan tool to grab only one profile, there really isn’t a point in telling it to avoid profiles older than 30 days. But I added it just to show how you can add several extra parameters to the command.

In this image, the variable has been set before I run the capture step.


UserState 51

This is the scanstateprogress.log


UserState 52

It shows that it ignores all profiles but the one I told it to grab.

Demo – Standard Setup, Defaults, Replacement Computer (Side-by-Side)

Making the Connection in the Console:


UserState 15
UserState 21

The Capture Task Sequence:


UserState 17

Triggering TS on Source Machine:


UserState 18

Checking the Console Now:


UserState 22

You can see that it updated the information, it has the store path, and time it was captured. Now let’s run the OSD TS on the Destination PC and updated to “In Progress”

Starting OSD on the Destination Computer:


UserState 20

The Machine Installs the OS and when it gets to the restore state, it reaches out to the MP and finds that there was user data to transfer, then copies it over creating the profile for the users that were backed up on the old machine.

UserState 23
UserState 24
UserState 25

So there we see the results of a successful transfer. The Console has updated, the destination has the files from the source, and the source has the scanstate logs, and the destination the loadstate logs.

Demo – Refresh – Keep USMT Data on local drive

This process is nice if you don’t have a fast connection back to the State Migration Point Server, and you need to keep the data local the entire time. It speeds up the entire process by keeping the data local. If you’re going to use this method, I recommend reading this MS Doc

The Task Sequence Step: Capture locally by using links.


UserState 28
UserState 34

For local hardlinks, make sure you disable the Request & Release User State Storage Steps, or you’ll get errors.

Make sure your format step has the condition on it!


UserState 29
And you can pick the location for USMT with a variable.
UserState 31

When it kicks off the Capture, you can see our location is being used.


UserState 30

Below on the Apply Image step, you can see it performs a few extra things: Wiping C:, Setting areas not to be wiped, then starting the wipe process.


UserState 32

Once the Wipe is complete, it starts to apply the image to the drive.


UserState 33

After it applies the OS, it installs the CM Client and reboots into the full OS, shortly after it runs the step to restore the user data.


UserState 36

On the Machine after logon, you can see the files have been restored. The USMTDemo folder was also cleaned up after the migration.


UserState 37

Demo – Side by Side – Recovering from Failed Transfer on new machine

In this demo, we’ll simulate an OSD Failure on the destination machine. We’ll look at the results, then see what we can do to recover.
Setup: Source = PC02 | Destination = PC10


UserState 38

I Ran the Capture TS on PC02:


UserState 39

Alright, so now lets start OSD on PC10.
And for this Demo, I’ll let the Restore Complete, then Kill OSD.


UserState 40

Now let’s Restart OSD and see how CM Responds to the Same Computer Requesting the Data backup the second time.


UserState 41

You can see, even though the console says complete, it’s running the restore without a problem. So that’s good news. It did finish successfully.

Demo – Capture User Data in WinPE

You can run this step in WinPE, however I had to make a couple changes to make this work.
First, I had to check the box to allow it to use the Network Access Account:
UserState 53](media/UserState53.png)

And update the OSDMigrateAdditionalCaptureOptions

/offlinewindir:c:\windows
UserState 54
UserState 55

When Completed:


UserState 56

Make sure you deal with any encryption before rebooting into WinPE if you want to backup the data!

Demo – Manually Extracting the .MIG file

Lets say you ran the capture process, and it uploaded to the server, and you restored it, but for whatever reason you find yourself needing to grab some individual files from the backup. In the USMT package, there is an exe called usmtutils.exe which you can use to extract the MIG file. MS Docs

Requirements:

  • Files: (Taken from the USMT Package)
    • usmtutils.exe
    • migcore.dll
    • migstore.dll
    • unbcl.dll
  • Encryption Key (Taken from CM Console)
  • Mig File Location (Take from CM Console)
  • Administrator Rights

Command line example:

usmtutils.exe /extract c:\usmt.mig c:\usmtextract /decrypt /key:73k3hn3k3k1kasdfkljhe1

In this demo, I grabbed the information from the CM Console


UserStateTrouble 4

I copied the 4 files into a folder (c:\USMT)
I wrote a simple script to plug in the values and trigger usmtutils:


UserStateTrouble 3

After the extract finished:


UserStateTrouble 5
Now you can grab the files you need without restoring to a computer during the TS.

Cheat the System – Restoring Data

Demo: Restore the data from State Migration Point to another computer using the Restore TS Steps

In this situation, the recovery was already complete, but I wanted to redirect the backup to a completely different computer.

I started by using several of the variables not in the docs to create the settings needed.

Required Variables:

  • OSDStateMigrationID – From CM Console
  • OSDStateStorePath – From CM Console: The location of the USMT.MIG backup.
  • OSDStateEncryptDecryptKey – From CM Console
  • OSDStateRequestType – set to Restore
  • OSDStateTalkToSMP – Server Name of the Migration Point
  • OSDStateUseNAA – Set to True* (Talked about more shortly)
UserState 47

Attempt 1 was with OSDStateUseNAA = False: FAILED, Access Denied to Storage
Attempt 2 was with OSDStateUseNAA = True: FAILED, Access Denied to Storage
Attempt 3 added my NAA Account to have Read permissions on the State Migration Point Share.
<img src=”media/UserState43.png” width=”350″/>

Once I did that, I decided to run the restore on PC08


UserState 46
UserState 45

Demo: Restore data by coping Local and running Restore Steps

If you don’t want to add NAA to your Restore Point, this is another option, and overall, it might be easier.

  • OSDStateStorePath – Manually Set to C:\USMTDemo
  • OSDStateEncryptDecryptKey – From CM Console
  • OSDStateRequestType – set to Restore

Copy the USMT File from the Migration Point local, for this demo I used C:\USMTDemo (C:\USMTDemo\USMT\USMT.mig)
I then setup my TS


UserState 49

You will still need to grab the Key from the Server for the backup you want to restore.
Then I pick my Demo machine, one I haven’t used before (PC06) and copy the USMT file local and trigger the new Restore Task Sequence. You can see below that it grabs the variables, finds the USMT file and restores it.


UserState 48

After complete, I can see it added the cmadmin account folders and populated the files from the USMT.


UserState 50

While these demos wouldn’t be a normal thing to do, in a pinch if you need to restore the data to another machine, you now have another option besides using straight up command lines.

Errors

When I was testing, I ran into a few problems, mostly around keeping the data local (Demo 3) as I had learned I needed to disable the request and release state storage steps, or you get an error like so, USMT: 0x00000006 TS:0x00004005


UserStateTrouble 2

Another error I received was forgetting to skip the format step. The machine errored when trying to format the drive as the USMT Folder created with the local storage transfer (hardlinking) was set to protected, and I received this error: 0x00000005 (Code 5)


UserStateTrouble 1
To Resolve, I ran diskpart clean to reset my test, then I added the condition on the format section of the TS to skip by setting the condition with _OSDMigrateUseHardlinks

Tips

This tip from Herman van Drie
(@hvandrie), “My experience with USMT hard-linked is you definitely want to run chkdsk before running usmt scan.”

Find all of our Task Sequence – Beyond the Docs series posts here.

About Recast Software

1 in 3 organizations using Microsoft Configuration Manager rely on Right Click Tools to surface vulnerabilities and remediate quicker than ever before.
Download Free Tools
Request Pricing

Back to Top