A customer requirement for a recent pilot project was to migrate user workstations to Vista for only a few weeks; we have to restore to the previous OS at the end of the pilot. There are other scenarios in which you’d need to restore a system using the fat WIM captured with the MDT Backup script in your deployment task sequence. Here’s a rough process to do the restore.
- Restart the computer to a generic WinPE 2.0 boot disk (that contains the necessary disk and network drivers).
- If the folder doesn’t already exist, create C:\_SMSTaskSequence\StateStore.
- Ensure the backup WIM is in that folder. If the deployment failed, the backup should be there already. If the deployment succeeded, the backup WIM should be at C:\Windows\Temp\StateStore; move it to C:\_SMSTaskSequence\StateStore. If there was insufficient space on the hard drive to store the backup (regardless of whether the deployment failed or succeeded) and you properly configured your CustomSettings.ini, the WIM will be on a network share. Copy it to C:\_SMSTaskSequence\StateStore (I recommend using robocopy /tee to see the progress).
- Double- and triple-check that everything you need from the system is copied off elsewhere or under C:\_SMSTaskSequence.
- Run cmd /v:on /c z:\wipe.cmd wipe to delete all content from C: except the _SMSTaskSequence folder (see wipe.cmd contents below).
- Map a drive to the deployment share (MDT or ConfigMgr server).
- Run Z:\Tools\x86\imagex.exe /apply C:\_SMSTaskSequence\StateStore\backup.wim 1 c:\ to restore.
- Type exit to restart to the previous OS.
Depending upon how your task sequence is configured, you may need to logon as the local administrator and rejoin to the domain.
You should be able to delete C:\_SMSTaskSequence at this point.
15 February 2009: I updated the script, which properly handles spaces in folder names (e.g., Documents and Settings, Program Files)
REM Wipe Drive script
REM Aaron Czechowski, Microsoft Consulting Services
REM 4 December 2007
REM display help if not parameter is specified
if !%1==! goto SYNTAX
REM initialize variable for total number of root files/folders
set /a intTotal=0
REM loop through each root file/folder and increment counter if it’s not C:\_SMSTaskSequence
FOR /f “delims=” %%i in (‘dir c:\ /b /a’) do if not %%i==_SMSTaskSequence set /a intTotal+=1
echo wiping drive …
REM initialize variable for current file/folder
set /a intCount=1
REM loop through each root file/folder,
REM if it’s not C:\_SMSTaskSequence, pass the object name to the PROCESSOR section
for /f “delims=” %%i in (‘dir c:\ /b /a /o:n’) do if not %%i==_SMSTaskSequence call :PROCESSOR “%%i”
echo Processing complete.
REM %%i variable from above “call” is interpreted here as the first parameter (%~1)
REM %~1 expands %1 removing any surrounding quotes (“)
REM !intCount! relies upon delayed environment variable expansion to be enabled
echo … deleting !intCount! of %intTotal% (%~1^)
del “c:\%~1” /q /f /a > NUL 2>&1
rmdir “c:\%~1” /s /q > NUL 2>&1
set /a intCount+=1
REM return to just after the “call” above
echo You must supply at least one argument to run this script.
echo Delayed environment variable expansion (/v:on) should be
echo enabled to correctly display the progress.
echo cmd /v:on /c wipe.cmd wipe