Capture User Files and Settings in Offline Mode (WinPE) with ConfigMgr 2007

In a previous postI already showed how to do a Hard-Link migration, when started from FullOS. That part still exists in my Task Sequence, but it is now moved under the Group Capture User Files and Settings – FullOS. This part will now only run when the Task Sequence is started from FullOS.

In this post I will add a part to the Task Sequence that makes sure that the User State will also be captured,  HardLinkOfflineTS when the Task Sequence is started from WinPE (also called Offline Mode). The cool part is that it will also be done by/ with using Hard-Links!

Capture User Files and Settings

For creating a Task Sequence, that does an Offline Capture, my way, a few variables and locations need to be created. After that a command line has to be run to do the actual Capture. Under here I will sum up the steps I take to do an Offline Capture (also see the red rectangle in the picture):

  • Set Started in WinPE – Set Task Sequence Variable
    This step sets the Task Sequence Variable TSStartedInWinPE to YES. This Task Sequence Variable only gets set when _SMSTSInWinPE is TRUE.
  • Capture User Files and Settings – WinPE – Group
    This group Captures the User Files and Settings when the machine is started from WinPE. This is done by checking if the Task Sequence Variable TSStartedInWinPE is set to YES.
  • Set Architecture – Set Task Sequence Variable
    This step sets the Task Sequence Variable Architecture to amd64. This variable will be used for selecting the USMT 4.0 version for 64-bit systems.
  • Set Windows Partition – Set Task Sequence Variable
    This step sets the Task Sequence Variable WindowsPartition to C:. This variable will be used for selecting the Windows partition.
  • Set State Store Location – Set Task Sequence Variable
    This step sets the Task Sequence Variable OSDStateStorePath to %WindowsPartition%\StateStore. This variable will be used for creating and selecting the User State Location.
  • Create State Store Location – Run Command Line
    This step creates the directory %WindowsPartition%\StateStore by running the Command line: cmd /c MKDIR %OSDStateStorePath%.
  • Cache USMT Files and Scripts – Run Command Line
    This step caches the USMT Files and Scripts from the USMT Package to the directory %OSDStateStorePath%\USMTFiles\ by running the Command line: xcopy * %OSDStateStorePath%\USMTFiles\ /herciy
  • Capture User Files and Settings – Run Command Line
    This step does the actual Capture of the User Files and Settings by running the Command line RunScanState.BAT %OSDStateStorePath% %WindowsPartition% %Architecture% which has to start in the directory %OSDStateStorePath%\USMTFiles\.

These are all the steps I need, to do an Offline Capture with Hard-Links. Now let’s take a closer look at the batch-file which does most of the work.

REM ============================================================
REM VARIABLE -1- OSDStateStorePath = %1
REM VARIABLE -2- WindowsPartition = %2
REM VARIABLE -3- Architecture = %3
REM ============================================================

SET USMT_WORKING_DIR=%1\USMTFiles\%3

REM ============================================================
REM RUN Scanstate
REM ============================================================

“%1\USMTFiles\%3\Scanstate.exe” “%1” /o /hardlink /nocompress /i:%1\USMTFiles\%3\miguser.xml i:%1\USMTFiles\%3\migapp.xml /offilinewindir:%2\Windows\TEMP\SMSTSLog\Scanstate.log /v:5 /progress:%2\Windows\TEMP\SMSTSLog\Scanstateprogress.log /c /efs:hardlink

REM ============================================================
REM EXIT Errorlevel
REM ============================================================

EXIT /b %errorlevel%

In this batch-file I am using three variables which are being set during the Task Sequence (and explained in the batch). The Scanstate command line, that is being used, is completely based on the standard syntax. Under here I created a table in which can be seen what every part of my command line stands for.

Command What does it do…
%1\USMTFiles\%3\scanstate.exe Scanstate.exe
%1 Specifies the folder where files and settings will be saved
/o Enables the possibility to overwrite existing data in de Migration Store.
/hardlink Enables the creation of a Hard-Link Migration Store
/nocompress Disables the compression of data.
/i:%1\USMTFiles\%3\miguser.xml Specifies an .xml file that contains rules that define what user, application or system state to migrate
/i:%1\USMTFiles\%3\migapp.xml Specifies an .xml file that contains rules that define what user, application or system state to migrate
/offlinewindir:%2\windows Specifies the Offline Windows directory that the ScanState command gathers user state from
/l:%2\windows\TEMP\SMSTSLog\Scanstate.log Specifies the location and name of the ScanState log
/v:5 Enables the verbose output in the ScanState log file
/progress:%2\windows\TEMP\SMSTSLog\Scanstateprogress.log Specifies the location and name of the ScanState progress log
/c Enables the ScanState command to continue to run, even if non-fatal errors occur
/efs:hardlink Enables the migration of encrypted files by creating a Hard-Link to the EFS file instead of copying it

Restore User Files and Settings

After the User Files and Settings have been captured, they need to be restored again to the new OS. For this I use the default Restore User Files and Settings step from ConfigMgr 2007 and the variable OSDMigrateAdditionalRestoreOptions. This variable is filled with the options /nocompress /hardlink, see for this also my previous post. This default step will restore everything that is found in the State Store Location.

With the red arrow in the picture I point at another important step (which is often forgotten). This step is the Cleanup User State Location, a Run Command Line step from ConfigMgr 2007. This step cleans up the State Store Location by running the command line RunUSMTutils.BAT %OSDStateStorePath% %Architecture% from the USMT 4.0 Package.

Now let’s take a look at the batch-file which does most of the work here.

REM ============================================================
REM VARIABLE -1- OSDStateStorePath = %1
REM VARIABLE -2- Architecture = %2
REM ============================================================

REM ============================================================
REM RUN USMTUtils
REM ============================================================

echo y| “%~dp0%2\usmtutils.exe” /rd “%1”

REM ============================================================
REM EXIT Errorlevel
REM ============================================================

EXIT /b %errorlevel%

The important part in here is the echo y|, because only running umstutils.exe /rd will ask for a confirmation on the action. I have to say that I really missed this in the documentation! So just use echo y| to pipeline a positive response on the confirmation, asked by the usmtutils.

Note: The RunScanState.BAT and the RunUSMTutils.BAT have to be placed inside the USMT Package at the same level as the amd64- and the x86-folder.

More information about the Scanstate Syntax:
http://technet.microsoft.com/en-us/library/dd560781(WS.10).aspx
More information about the LoadState Syntax:
http://technet.microsoft.com/en-us/library/dd560804(WS.10).aspx
More information about the USMTUtils Syntax: http://technet.microsoft.com/en-us/library/dd560799(WS.10).aspx

4 thoughts on “Capture User Files and Settings in Offline Mode (WinPE) with ConfigMgr 2007”

  1. Hi Peter,

    Very nice your article, I did here and is working, but I have a different cenario. I have drive D: and this drive are located all profiles, my default image was created to change the path. Is there on way to scan the drive D: in scanstate?

    I followed this link below and is working with images that no have more than one drive.

    Can you help me in this case?

    thank you in advance.

    Reply
  2. @Peter
    good job…but your merged the parameters /offlinewindir and /L in your batch script! I think that this was a mistake and your original script is running perfect
    Thanks for posting the article

    Reply

Leave a Comment

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