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.
Request State Store
This step will reach out to your ConfigMgr Environment, request a location to capture the user data to.
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.
- _OSDMigrateUseHardlinks – Used for condition on Format Step
Restore User State
This is the step that restores the data you captured earlier.
Release State Store
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 approprate log. The log will be in the SMSTSLOG subfolder while the TS is running, or merged in after. More info on MS Docs
State Migration Point
Demo – Standard Setup, Defaults, Same Computer (Wipe & Load)
Here is what MS creates when you build a TS using the wizard:
And here it is in action:
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)
Capture User State:
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.
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:viamonstrarecast = 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.
Demo – Standard Setup, Defaults, Replacement Computer (Side-by-Side)
The Capture Task Sequence:
Triggering TS on Source Machine:
Checking the Console Now:
You can see that it updated the information, it has the store path, and time it was captured. Now lets run the OSD TS on the Destination PC and updated to “In Progress”
Starting OSD on the Destination Computer:
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.
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
Make sure your format step has the condition on it!
And you can pick the location for USMT with a variable.
When it kicks off the Capture, you can see our location is being used.
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.
Once the Wipe is complete, it starts to apply the image to the drive.
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.
Demo – Side by Side – Recovering from Failed Transfer on new machine
Alright, so now lets start OSD on PC10.
And for this Demo, I’ll let the Restore Complete, then Kill OSD.
Now lets Restart OSD and see how CM Responds to the Same Computer Requesting the Data backup the second time.
You can see, even though th 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:
And update the OSDMigrateAdditionalCaptureOptions
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
- Files: (Taken from the USMT Package)
- 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
I copied the 4 files into a folder (c:USMT)
I wrote a simple script to plug in the values and trigger usmtutils:
After the extract finished:
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 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.
- 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)
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″/>
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:USMTDemoUSMTUSMT.mig)
I then setup my TS
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.
After complete, I can see it added the cmadmin account folders and populated the files from the USMT.
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.
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
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)
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
This tip from Herman van Drie
(@hvandrie), “My experience with USMT hard-linked is you definitely want to run chkdsk before running usmt scan.”
More Task Sequence Steps – Beyond the Docs
Find all of our Task Sequence – Beyond the Docs series posts here.