Tuesday, October 1, 2013

Step 1.3.1: Migration

One of the requirements for All in one Task Sequence is to migrate the data in WinPE / Offline Mode.
The benefits of WinPE mode are, all the files can be copied without file or folder lock and it is faster. The main drawback is you cannot use Capture User State in WinPE. So to go around with this issue, we will create a USMT package and run the commands manually.
Also I will use a network share to store the user data rather using SMP.

Create Migration folder Under Evaluate Build type. The Migration group will be executed if the following conditions are met;

The Migration activity is divided into State Store Migration and Prepare the Drives.

State Store Migration:
Create a State Store Migration folder. Add MDT toolkit package and choose MDT 2012 package (or add whatever MDT you have) then add Gather step then select Gather only local data (do not process rules)

Add Set Task Sequence Variable and name it as Set System Drive TS Variable. We need to tell the task sequence which drive is System drive. Normally in WinPE mode, Task Sequence will pick the system drive as X: drive. To avoid this we will create a custom Task Sequence variable and force the task sequence to use C drive as system drive.
On Set task Sequence variable step;
      Task Sequence Variable:  Systemdrive
      Value: C:

Create Map data Store by creating a Connect to Network Folder. In Path box choose the UNC path of the location where you want to store, assign a drive letter and add an account which has access rights.
I have created a folder called migration and shared with all the users. For production environments, you need to assign appropriate permissions to the service account so the service account can Read and Write the data to this folder.

Add Run command line step to create a machine name folder within the Migration folder to back up the USMT data. In Command line add cmd /c MD L:\%_SMSTSMachinename%

If we fail to create the machine name folder on the Migration folder, the USMT data will be over written when we run USMT on the second machine. By add machine name folder, we making sure that the data will be stored on the individual machine and we can use that data for future manual restores if required.
Add Set Task Sequence Variable step to create a custom Task Sequence variable for OSD state store path.
               Task Sequence Variable: OSDStateStorePath
               Value: \\SCCM\migration\%_SMSTSMachinename%

Replace \\SCCM\Migration as needed.
Add an other Set Task Sequence Variable step to add additional Capture Options
            Task Sequence Variable: OSDMigrateAdditionalCaptureOptions
            Value: /nocompress



Create a USMToffline.cmd file and add following command to the .cmd file.
USMTOffline.cmd
***************************************************************************
@echo off
REM Creating Offline USMT folder under C:
IF EXIST "C:\USMTOffline" RMDIR C:\USMTOffline /S /Q
MD %Systemdrive%\USMTOffline

REM Creating a USMT local source folder
IF EXIST "C:\USMTSource" RMDIR C:\USMTSource /S /Q

MD %Systemdrive%\USMTSource
EXIT
****************************************************************************
Create a package (USMTOffline) and USMTOffline.cmd to this package.

Now we need to add USMTOffline package content to WinPE Windows drive by adding Run Command Line then add XCOPY ".\*.*" "%WinDir%" /E /C /Q /H /R /Y /I in Command line.

Add another Run Command line step  then name it as Execute USMT copy then add cmd /c start %WinDir%\USMTScript.cmd

The USMTScript will create USMTOffline and USMTSource folders under C:\. If it is already exist in that location, the script will delete the folders then will re-create it.
Creating USMT offline folder under C:\ can be achieved easily by adding MD C:\USMTOffline and MD C:\USMTSource.
To make process easy I have created a package for the .cmd file then added to the WinPE then ran from there.

Create a USMT package (called USMT) using the source from <Program Files>\Windows AIK\Tools\USMT The source should have amd64 and x86 folders under USMT folder.
Add a Run command line to Copy USMT Source to C:\USMTSource folder as below;

Create a package (Called ScanState) then add Loadstate.cmd and ScanState.cmd to the package.

Loadstate.cmd
*****************************************************************************
@echo off
@set USMT_WORKING_DIR=%~2%\USMTSource\amd64

"%~2\USMTSource\amd64\Loadstate.exe" "%~1" /c /nocompress /ue:%computername%\* /v:5 /l:%~2\windows\TEMP\SMSTSLog\Loadstate.log /progress:%~2\windows\TEMP\SMSTSLog\Loadstateprogress.log /i:"%~2\USMTSource\amd64\miguser.xml" /i:"%~2\USMTSource\amd64\migapp.xml"
*******************************************************************************

ScanState.cmd
******************************************************************************
@echo off
@set USMT_WORKING_DIR=%~2%\USMTSource\amd64

"%~2\USMTSource\amd64\scanstate.exe" "%~1" /c /o /nocompress /localonly /offlinewindir:C:\Windows /v:5 /l:%~2\windows\TEMP\SMSTSLog\scanstate.log /progress:%~2\windows\TEMP\SMSTSLog\scanstateprogress.log /i:"%~2\USMTSource\amd64\miguser.xml" /i:"%~2\USMTSource\amd64\migapp.xml"
*******************************************************************************
Copy the ScanState package content to C:\USMTSource by adding Run Command line, then xcopy %_SMSTSLAB00029%* %systemdrive%\USMTSource\ /herciy in Command line box.

Add Run Command line step and name it as Run Scan state then add the commands as below

Add Run Command line and name is REG Unload. On command line box add:
cmd /c REG Unload HKLM\$DEST$Software
Add Restart Computer and under Specify what to run after restart; select The boot image assigned to this task sequence.

At this stage out All in One Task Sequence looks as below;

Click here for complete list of tasks for SCCM OSD All in one task sequence.
Click here for SCCM OSD All in one task sequence Visio diagram.

2 comments:

  1. I cannot get my Options "If Statement" to look like your setup. You have two root conditions, an ANY and a NONE. I cannot get two root conditions, I can make a "If Any the conditions are true" and then an ANY and NONE beneath that. Is this a version difference and is that the intended logic, an ANY with sub ALL and NONE?

    ReplyDelete
  2. Hi,
    You add a second If statement then choose desired settings.

    ReplyDelete