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
- Get-CMTSStepRequestStateStore
- New-CMTSStepRequestStateStore
- Remove-CMTSStepRequestStateStore
- Set-CMTSStepRequestStateStore
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.
Variables
- _OSDMigrateUseHardlinks – Used for condition on Format Step
- _OSDMigrateUsmtPackageID
- OSDMigrateAdditionalCaptureOptions
- OSDMigrateConfigFiles
- OSDMigrateContinueOnLockedFiles
- OSDMigrateEnableVerboseLogging
- OSDMigrateMode
- OSDMigrateSkipEncryptedFiles
- OSDStateStorePath
PowerShell
- Get-CMTSStepCaptureUserState
- New-CMTSStepCaptureUserState
- Remove-CMTSStepCaptureUserState
- Set-CMTSStepCaptureUserState
Restore User State
This is the step that restores the data you captured earlier.
Variables
- _OSDMigrateUsmtRestorePackageID
- OSDMigrateAdditionalRestoreOptions
- OSDMigrateContinueOnRestore
- OSDMigrateEnableVerboseLogging
- OSDMigrateLocalAccounts
- OSDMigrateLocalAccountPassword
- OSDStateStorePath
PowerShell
- Get-CMTSStepRestoreUserState
- New-CMTSStepRestoreUserState
- Remove-CMTSStepRestoreUserState
- Set-CMTSStepRestoreUserState
Release State Store
Variables
PowerShell
- Get-CMTSStepReleaseStateStore
- New-CMTSStepReleaseStateStore
- Remove-CMTSStepReleaseStateStore
- Set-CMTSStepReleaseStateStore
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
Demos
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)
Request State Store:
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.
Release State Store:
This step removes the connection to the server
Variables used in TS, the store path gets wiped after you release the state store.
On the Server:
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.
This is the scanstateprogress.log
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:
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 let’s 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
The Task Sequence Step: Capture locally by using links.
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!
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.
On the Machine after logon, you can see the files have been restored. The USMTDemo folder was also cleaned up after the migration.
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
I Ran the Capture TS on PC02:
Alright, so now lets start OSD on PC10.
And for this Demo, I’ll let the Restore Complete, then Kill OSD.
Now let’s Restart OSD and see how CM Responds to the Same Computer Requesting the Data backup the second time.
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
When Completed:
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
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 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)
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
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
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.
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
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
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