How to apply Task Sequence Prestaged Media on multi-partitioned disks for BIOS or UEFI PCs in System Center Configuration Manager

How to apply Task Sequence Prestaged Media on multi-partitioned disks for BIOS or UEFI PCs in System Center Configuration Manager

  • Comments 14
  • Likes

The TechNet documentation for System Configuration Manager contains instructions for creating Prestaged Media at the below links:

System Center Configuration Manager 2007
How to Create Task Sequence Prestaged Media
http://technet.microsoft.com/en-us/library/gg294170.aspx

System Center 2012 Configuration Manager
How to Deploy Operating Systems by Using Media in Configuration Manager
How to Create Prestaged Media
http://technet.microsoft.com/en-us/library/79465d90-4831-4872-96c2-2062d80f5583#BKMK_CreatePrestagedMedia

However there are no instructions on TechNet regarding how to apply the Prestaged Media to a hard drive for delivery to an OEM. The following article covered single partition scenarios for BIOS PCs:

How to stage Task Sequence Prestaged Media on a hard drive in Configuration Manager 2007
http://blogs.technet.com/b/configurationmgr/archive/2011/01/11/how-to-stage-task-sequence-prestaged-media-on-a-hard-drive-in-configuration-manager-2007.aspx

However, the article does not cover multi-partitioned scenarios such as:

  1. BIOS PCs where the boot partition is separate from the OS partition. This is the default configuration for Windows 7 and newer and common in BitLocker scenarios.

  2. UEFI PCs where separate EFI, MSR, and OS partitions are required (Recovery partition could also optionally exist).

This article will cover how to properly apply Task Sequence Prestaged Media on multi-partitioned volumes. Since Prestaged Media was introduced in R2 of ConfigMgr 2007, this article is only applicable when either R2 or R3 is installed as part of ConfigMgr 2007 SP2 or when using ConfigMgr 2012.

How To Apply Task Sequence Prestaged Media on Multi-partitioned Disks

There are two ways to properly apply a Task Sequence Prestaged Media on a hard drive:

  • Manually
  • Automated Via A Task Sequence

Click on the section below to take you to the area of your interest:


Manually Apply A Task Sequence Prestaged Media On A Hard Drive

The steps for applying Prestaged Media are different for BIOS PCs vs. UEFI PCs, therefore two different sections are provided - one for BIOS PCs and another for UEFI PCS. Please select the method that is applicable:

BIOS PCs:

The following instructions apply to BIOS PCs for both ConfigMgr 2007 SP2 R2/R3 and ConfigMgr 2012 SP1 and newer.

1. On the PC where the Prestaged Media needs to be applied onto the hard drive, boot into WinPE via a ConfigMgr boot image that has command prompt support enabled. The method by which booting into WinPE (PXE, USB Flash Media, CD/DVD Media) does not matter.

As an alternative a custom non-ConfigMgr WinPE boot image can be used. If using a custom WinPE boot image, please make sure it is a WinPE 4 or newer boot image, even if using ConfigMgr 2007. If a custom non-ConfigMgr WinPE boot image is being used, boot into the custom WinPE boot image and then skip to Step 3.

Please note the following:

  • If using ConfigMgr PXE to boot into WinPE, you may need to optionally deploy a Task Sequence to the PC to get the PC to boot into WinPE. Any Task Sequence should work.
  • If using USB Flash Media, it may be beneficial to copy the Prestaged Media to the USB Flash Media for easier access later in the process

2. Once in WinPE, when the Task Sequence Wizard is displayed, hit F8 to open a command prompt window. DO NOT click on the Next > button in the Task Sequence Wizard window or proceed with picking a Task Sequence to run. Once you have hit F8 and a command prompt window is open, you can click on the Cancel button in the Task Sequence Wizard to dismiss it. As long as the command prompt window is open, the computer will not reboot automatically.

When the command prompt window opens it will do so with an X:\ command prompt. Please note that the path of the command prompt may be X:\sms\bin\x64 or X:\sms\bin\i386. This is normal and the path does not need to be changed. For any additional references to the X:\ command prompt in the below steps, please assume X:\sms\bin\x64 or X:\sms\bin\i386 to be the same as X:\.

3. In the command prompt window, at the X:\ command prompt type in:

DiskPart

This should give the DISKPART> prompt.

4. At the DISKPART> prompt, type in the following commands in the order specified below. Make sure to hit Enter after each command:

Select Disk 0
Clean
Create Partition Primary Size=350
Active
Format FS=NTFS Label="System Reserved" Quick Override
Assign Letter=S
Create Partition Primary
Format FS=NTFS Label=OS Quick Override
Assign Letter=C

The above commands will set up two partitions:

  • A boot partition of size 350MB formatted NTFS with the name "System Reserved" and assigned a drive letter of S:.
  • An OS partition that utilizes the remaining hard drive space formatted NTFS with the name "OS" and assigned a drive letter of C:

5. To confirm the partitioning from Step 4, at the DISKPART> prompt, type in:

List Volume

This will list all of the volumes on all of the drives attached to the PC and should allow confirmation that the partitioning was set up correctly. If the Prestaged Media is located on a local drive connected to the PC such as a USB Flash Drive, also note the drive letter of that drive for use later in the process.

6. Once the partitioning has been determined to be correct, at the DISKPART> prompt, type in:

Exit

This will exit DiskPart and go back to the X:\ command prompt.

7. If the Prestaged Media is not located on a local drive connected to the PC such as a USB Flash Drive, use the Net Use command to connect to a network share that contains the Prestaged Media.

8. At the X:\command prompt, type in:

WinPE 4 or newer boot image (default in ConfigMgr 2012 SP1 and newer)

DISM.exe /Apply-Image /ImageFile:<Path_To_Prestaged_Media_File> /Index:1 /ApplyDir:C:\

where Path_To_Prestaged_Media_File is the path to the Prestaged Media from Steps 5 or 7. Do not include the brackets (<>) in the path.

WinPE 3.x boot image (default in ConfigMgr 2007 SP2 R2/R3)

imagex.exe /apply <Path_To_Prestaged_Media_File> 1 C:

where Path_To_Prestaged_Media_File is the path to the Prestaged Media from Steps 5 or 7. Do not include the brackets (<>) in the path.

Note: Imagex.exe is not included in the WinPE 3.x boot image. It will need to be obtained from the Windows AIK\Tools\<architecture> folder from the Windows Automated Installation Kit (WAIK) 2.0 installation on the ConfigMgr 2007 site server. Once the appropriate version of imagex.exe that matches the architecture of the boot image has been obtained, in will need to be copied to a location that can be accessed during the process, such as a network drive or local USB Flash Drive.

This step will apply the Prestaged Media to the OS partition and will take a few minutes to complete.

9. After the Prestaged Media has finished applying, at the X:\ command prompt, type in:

WinPE 4 or newer boot image (default in ConfigMgr 2012 SP1 and newer)
bcdboot.exe C:\Windows /s S: /f BIOS

WinPE 3.x boot image (default in ConfigMgr 2007 SP2 R2/R3)
bcdboot.exe C:\Windows /s S:

This step will copy critical boot files to the boot partition (S:) and create a new BCD store.

10. At the X:\ command prompt, type in:

DEL S:\boot\bcd /f /q

This will delete the default BCD store created in Step 9 by the bcdboot.exe command in preparation for creating a custom BCD store.

11. At the X:\ command prompt, type in:

COPY C:\boot\bcd S:\boot /y

This will copy the BCD store created by the Prestaged Media to the boot partition (S:).

12. At the X:\ command prompt, type in the following BCDEdit commands in the order specified below. Make sure to hit Enter after each command:

BCDEdit.exe /Store S:\Boot\BCD /Set {ramdiskoptions} ramdisksdidevice partition=C: 
BCDEdit.exe /Store S:\Boot\BCD /Set {Default} device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions} 
BCDEdit.exe /Store S:\Boot\BCD /Set {Default} osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}

BCDEdit.exe /Store S:\Boot\BCD -set {bootmgr} device partition=S:

These BCDEdit commands set up the BCD store to boot WinPE from the hard drive into a RAM disk. The WinPE on the hard drive is the one that was created by the Prestaged Media.

In ConfigMgr 2012 SP1, the variable OSDPreserveDriveLetter was added that allowed an administrator to specify what they wanted the drive letter to be in the new Windows OS. If OSDPreserveDriveLetter is set to TRUE (default), it will use the drive letter assigned in the captured OS WIM. If OSDPreserveDriveLetter is set to FALSE, it will use the drive letter assigned to the OS partition in WinPE. In most cases administrators want the new Windows OS to be assigned a drive letter of C:. However under certain scenarios, this may not be possible using the OSDPreserveDriveLetter variable. Consider the following scenario:

  • Captured OS WIM has a drive letter other than C:. For example Install.WIM from the installation source files of some Windows versions are captured with drive letter D:.

  • The OS partition is assigned a drive letter other than C: in WinPE. For example, in the above Prestaged Media configuration, when the PC boots into WinPE from the Prestaged Media, the boot partition would receive a drive letter of C: (since it is the first partition) and the OS partition would receive a drive letter of D: (since it is the second partition).

In the above scenario since both the captured OS WIM and the OS partition in WinPE are assigned a drive letter of D:, regardless of what the variable OSDPreserveDriveLetter is set to, the new Windows OS will end up on drive letter D:. This is undesirable for most administrators.

To resolve the problem, commands can be added to the winpeshl.ini file that reassigns drive letters in WinPE so that the OS partition is given a drive letter of C:. This is can be done via a DiskPart script that is launched by winpeshl.ini before it launches the Task Sequence. Winpeshl.ini is the file that controls what is launched after WinPE finishes loading.

To implement the solution follow the below steps. If you are using ConfigMgr 2007 or you do not want to implement the solution, skip to Step 24 to complete applying the Prestaged Media to the hard drive.

13. At the X:\ command prompt, type in:

md c:\windows\temp\mount

This will create a temporary directory to mount the boot image from the Prestaged Media to.

14. At the X:\ command prompt, type in the following command to mount the boot image from the Prestaged Media:

DISM.exe /Mount-Image /ImageFile:C:\sources\boot.wim /Index:1 /MountDir:C:\Windows\Temp\Mount

15. At the X:\ command prompt, type in the following command to open NotePad:

NotePad.exe

16. Copy the below lines and then paste in NotePad:

Select Disk 0
Select Partition 1
Assign Letter=S
Select Partition 2
Assign Letter=C

Exit

This will create a DiskPart script that assigns a drive letter of S: to the boot partition and a drive letter of C: to the OS partition. This DiskPart script will be used later in the process.

17. In NotePad, go to File --> Save:

  • Navigate to the following path

    C:\Windows\Temp\Mount\Windows\temp

  • Next to Save as type: switch from Text Documents (*.txt) to All Files (*.*).

  • Next to File name:, type in

    diskpart-bios.txt

  • Click on the Save button.

18. In NotePad, go to File --> Open:

  • Navigate to the following path

    C:\Windows\Temp\Mount\Windows\System32

  • Next to File name: switch from Text Documents (*.txt) to All Files (*.*).

  • Locate and then double click on:

    winpeshl.ini

    to open it.

19. Depending on the architecture, the winpeshl.ini file will have one of the following two configurations:

x64
[LaunchApps]
%SYSTEMDRIVE%\sms\bin\x64\TsBootShell.exe


x86
[LaunchApps]
%SYSTEMDRIVE%\sms\bin\i386\TsBootShell.exe

Replace and overwrite the contents of the existing winpeshl.ini file by copying and pasting the lines below into the file. Make sure to choose the appropriate architecture:

x64
[LaunchApps]
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-bios.txt
%SYSTEMDRIVE%\sms\bin\x64\TsBootShell.exe


x86
[LaunchApps]
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-bios.txt
%SYSTEMDRIVE%\sms\bin\i386\TsBootShell.exe

The above steps will create an updated winpeshl.ini file. Any commands in the winpeshl.ini file will run automatically when WinPE starts up. In this case the following actions take place:

  • Runs a DiskPart script that assigns the boot partition a drive letter of S: and the OS partition a drive letter of C:
  • Runs the Task Sequence Wizard (which is used to launch the Task Sequence)

20. In NotePad save the changes to the winpeshl.ini file by going to File --> Save.

21. Close out of NotePad by going to File --> Exit.

22. At the X:\ command prompt, type in:

DISM.exe /Unmount-Image /MountDir:C:\Windows\Temp\Mount /Commit

This will save the boot image with the DiskPart script and updated winpeshl.ini.

23. At the X:\ command prompt, type in:

rmdir c:\windows\temp\mount /s /q

This will clean up the mount directory by deleting it.

24. At the X:\ command prompt, type in:

wpeutil shutdown

This will shut down the PC.

Unless testing to make sure the Prestaged Media works, DO NOT turn the PC back on after Step 24 or else the whole process will need to be repeated from Step 1. A this point the Task Sequence Prestaged Media file has been successfully applied to the hard drive of the PC and the boot partition has been properly prepared to be booted from the Prestaged Media. The hard drive should be ready for delivery to the OEM.

 

UEFI PCs:

The following instructions apply to UEFI PCs for ConfigMgr 2012 SP1 and newer. Since UEFI support was introduced in ConfigMgr 2012 SP1, the below steps are not intended for ConfigMgr 2007 SP2 R2/R3.

1. On the PC where the Prestaged Media needs to be applied onto the hard drive, boot into WinPE via a ConfigMgr boot image that has command prompt support enabled. The method by which booting into WinPE (PXE, USB Flash Media, CD/DVD Media) does not matter.

As an alternative a custom non-ConfigMgr WinPE boot image can be used. If a custom non-ConfigMgr WinPE boot image is being used, skip to Step 3.

Please note the following:

  • If using ConfigMgr PXE, you may need to optionally deploy a Task Sequence to the PC to get the PC to boot into WinPE. Any Task Sequence should work.
  • If using USB Flash Media, it may be beneficial to copy the Prestaged Media to the USB Flash Media for easier access later in the process.

2. Once in WinPE, when the Task Sequence Wizard is displayed, hit F8 to open a command prompt window. DO NOT click on the Next > button in the Task Sequence Wizard window or proceed with picking a Task Sequence to run. Once you have hit F8 and a command prompt window is open, you can click on the Cancel button in the Task Sequence Wizard to dismiss it. As long as the command prompt window is open, the computer will not reboot automatically.

When the command prompt window opens it will do so with an X:\ command prompt. Please note that the path of the command prompt may be X:\sms\bin\x64 or X:\sms\bin\i386. This is normal and the path does not need to be changed. For any additional references to the X:\ command prompt in the below steps, please assume X:\sms\bin\x64 or X:\sms\bin\i386 to be the same as X:\.

3. In the command prompt window, at the X:\ command prompt type in:

DiskPart

This should give the DISKPART> prompt.

4. At the DISKPART> prompt, type in the following commands in the order specified below. Make sure to hit Enter after each command:

Select Disk 0
Clean
Convert GPT
Create Partition EFI Size=500
Format FS=fat32 Label=EFI Quick Override
Assign Letter=S
Create Partition MSR Size=128
Create Partition Primary
Format FS=NTFS Label=OS Quick Override
Assign Letter=C


If a Recovery partition is desired, add the following commands in between the Convert GPT and Create Partition EFI Size=500 commands. Please note that the Recovery partition is optional and not required for UEFI PCs:

Create Partition Primary Size=300
Format FS=NTFS Label=Recovery Quick Override
Set ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
GPT Attributes=0x8000000000000001
Attributes Volume Set NoDefaultDriveLetter

The above commands will convert the disk to a GPT disk (required for UEFI PCs) and set up the following partitions:
  • If creating the optional Recovery partition, a partition of size 300MB formatted NTFS with the name "Recovery". The partition is not assigned a drive letter and is marked as required to prevent users from deleting it.
  • An EFI (boot) partition of size 500MB formatted FAT32 with the name "EFI" and assigned a drive letter of S:. The EFI partition must be formatted FAT32 and cannot be NTFS.
  • An MSR partition of size 128MB. An MSR partition is required for UEFI PCs. MSR partitions are not formatted.
  • An OS partition formatted NTFS that utilizes the remaining hard drive space with the name "OS" and assigned a drive letter of C:.

5. To confirm the partitioning from Step 4, at the DISKPART> prompt, type in:

List Volume

This will list all of the volumes on all of the drives attached to the PC and should allow confirmation that the partitioning was set up correctly. If the Prestaged Media is located on a local drive connected to the PC such as a USB Flash Drive, also note the drive letter of that drive for use later in the process.

The MSR partition will not be displayed when using the List Volume command. To list all partitions on the disk including the MSR partition use the List Partition command instead.

6. Once the partitioning has been determined to be correct, at the DISKPART> prompt, type in:

Exit

This will exit DiskPart and go back to the X:\ command prompt.

7. If the Prestaged Media is not located on a local drive connected to the PC such as a USB Flash Drive, use the Net Use command to connect to a network share that contains the Prestaged Media.

8. At the X:\ command prompt, type in:

DISM.exe /Apply-Image /ImageFile:<Path_To_Prestaged_Media_File> /Index:1 /ApplyDir:C:\

where Path_To_Prestaged_Media_File is the path to the Prestaged Media from Step 5 or 7. Do not include the brackets (<>) in the path.

This step will apply the Prestaged Media to the OS partition and will take a few minutes to complete.

9. After the Prestaged Media has finished applying, at the X:\ command prompt, type in:

bcdboot.exe C:\Windows /s S: /f UEFI

This step will copy critical boot files to the EFI partition (S:) and create a new BCD store.

10. At the X:\ command prompt, type in:

DEL S:\EFI\Microsoft\Boot\BCD /f /q

This will delete the default BCD store created in Step 9 by the bcdboot.exe command in preparation for creating a custom BCD store.

11. At the X:\ command prompt, type in:

COPY C:\EFI\Microsoft\Boot\BCD S:\EFI\Microsoft\Boot /y

This will copy the BCD store created by the Prestaged Media to the EFI partition (S:).

12. At the X:\ command prompt, type in the following BCDEdit commands in the order specified below. Make sure to hit Enter after each command:

BCDEdit.exe /Store S:\EFI\Microsoft\Boot\BCD /Set {ramdiskoptions} ramdisksdidevice partition=C:
BCDEdit.exe /Store S:\EFI\Microsoft\Boot\BCD /Set {Default} device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
BCDEdit.exe /Store S:\EFI\Microsoft\Boot\BCD /Set {Default} osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
BCDEdit.exe /Store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} device partition=S:


These BCDEdit commands set up the BCD store to boot WinPE from the hard drive into a RAM disk. The WinPE on the hard drive is the one that was created by the Prestaged Media.

There is a know issue in ConfigMgr 2012 SP1 and ConfigMgr 2012 R2 where when booting from Prestaged Media on a UEFI PC, after applying the Prestaged Media, it will boot successfully to the Task Sequence Wizard the first time the PC is booted. However if a Task Sequence is not selected from the Task Sequence Wizard and instead the Task Sequence Wizard is canceled, the PC will restart and any subsequent boots will not succeed. The reason that this happens is that the Task Sequence Wizard deletes the boot files from the EFI partition.

This issue can be worked around by adding commands to the winpeshl.ini file that backs up the boot files from the EFI partition and later restores the boot files after the Task Sequence has deleted them. Winpeshl.ini is the file that controls what is launched after WinPE finishes loading.

To implement the workaround follow the below steps. If you do not want to implement the workaround, skip to Step 24 to complete applying the Prestaged Media to the hard drive.

13. At the X:\ command prompt, type in:

md c:\windows\temp\mount

This will create a temporary directory to mount the boot image from the Prestaged Media to.

14. At the X:\ command prompt, type in the following command to mount the boot image from the Prestaged Media:

DISM.exe /Mount-Image /ImageFile:C:\sources\boot.wim /Index:1 /MountDir:C:\Windows\Temp\Mount

15. At the X:\ command prompt, type in the following command to open NotePad:

NotePad.exe

16. Copy the below lines and then paste in NotePad:

Select Disk 0
Select Partition 1
Assign Letter=S
Exit

If a Recovery partition was created in Step 4, change the line Select Partition 1 to Select Partition 2.

This will create a DiskPart script that assigns a drive letter of S: to the EFI partition. This DiskPart script will be used later in the process.

17. In NotePad, go to File --> Save:
  • Navigate to the following path

    C:\Windows\Temp\Mount\Windows\temp

  • Next to Save as type: switch from Text Documents (*.txt) to All Files (*.*).

  • Next to File name:, type in

    diskpart-efi.txt

  • Click on the Save button.

18. In NotePad, go to File --> Open:

  • Navigate to the following path

    C:\Windows\Temp\Mount\Windows\System32
  • Next to File name: switch from Text Documents (*.txt) to All Files (*.*).
  • Locate and then double click on:

    winpeshl.ini

    to open it.

19. Depending on the architecture, the winpeshl.ini file will have one of the following two configurations:

x64
[LaunchApps]
%SYSTEMDRIVE%\sms\bin\x64\TsBootShell.ex


x86
[LaunchApps]
%SYSTEMDRIVE%\sms\bin\i386\TsBootShell.ex

Replace and overwrite the contents of the existing winpeshl.ini file by copying and pasting the lines below into the file. Make sure to choose the appropriate architecture:

x64
[LaunchApps]
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-efi.txt
%windir%\system32\xcopy.exe, /e S:\EFI\*.* C:\Windows\temp\EFIOrg\*.* /H /Y
%SYSTEMDRIVE%\sms\bin\x64\TsBootShell.exe
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-efi.txt
%windir%\system32\xcopy.exe, /e S:\EFI\*.* C:\Windows\temp\EFINew\*.* /H /Y
%windir%\system32\xcopy.exe, /e C:\Windows\temp\EFIOrg\*.* S:\EFI\*.* /H /Y
%windir%\system32\xcopy.exe, /e C:\Windows\temp\EFINew\*.* S:\EFI\*.* /H /Y
%windir%\system32\cmd.exe, /c rmdir C:\Windows\temp\EFIOrg /s /q
%windir%\system32\cmd.exe, /c rmdir C:\Windows\temp\EFINew /s /q


x86
[LaunchApps]
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-efi.txt
%windir%\system32\xcopy.exe, /e S:\EFI\*.* C:\Windows\temp\EFIOrg\*.* /H /Y
%SYSTEMDRIVE%\sms\bin\i386\TsBootShell.exe
%windir%\system32\diskpart.exe, /s x:\windows\temp\diskpart-efi.txt
%windir%\system32\xcopy.exe, /e S:\EFI\*.* C:\Windows\temp\EFINew\*.* /H /Y
%windir%\system32\xcopy.exe, /e C:\Windows\temp\EFIOrg\*.* S:\EFI\*.* /H /Y
%windir%\system32\xcopy.exe, /e C:\Windows\temp\EFINew\*.* S:\EFI\*.* /H /Y
%windir%\system32\cmd.exe, /c rmdir C:\Windows\temp\EFIOrg /s /q
%windir%\system32\cmd.exe, /c rmdir C:\Windows\temp\EFINew /s /q

The above steps will create an updated winpeshl.ini file. Any commands in the winpeshl.ini file will run automatically when WinPE starts up. In this case the following actions take place:

  • Runs a DiskPart script that assigns the EFI partitions a drive letter of S:
  • Backs up the contents of the original EFI partition
  • Runs the Task Sequence Wizard (which is used to launch the Task Sequence)
  • Runs a DiskPart script that assigns the EFI partitions a drive letter of S: (in case the drive letter was lost if a Task Sequence ran)
  • if no Task Sequence ran, this step will not do anything)
  • Restores the original EFI partition
  • Restores the current EFI partition (if no Task Sequence ran, this step will not do anything)
  • Cleans up the backed up EFI partitions

20. In NotePad save the changes to the winpeshl.ini file by going to File --> Save.

21. Close out of NotePad by going to File --> Exit.

22. At the X:\ command prompt, type in:

DISM.exe /Unmount-Image /MountDir:C:\Windows\Temp\Mount /Commit

This will save the boot image with the DiskPart script and updated winpeshl.ini.

23. At the X:\ command prompt, type in:

rmdir c:\windows\temp\mount /s /q

This will clean up the mount directory by deleting it.

24. At the X:\ command prompt, type in:

wpeutil shutdown

This will shut down the PC.

Unless testing to make sure the Prestaged Media works, DO NOT turn the PC back on after Step 24 or else the whole process may need to be repeated from Step 1. A this point the Task Sequence Prestaged Media file has been successfully applied to the hard drive of the PC and the boot partition has been properly prepared to be booted from the Prestaged Media. The hard drive should be ready for delivery to the OEM.

Please note that the problem where the OS does not end up on drive letter C: as described under the BIOS section usually only occurs on BIOS PCs. It does not occur on UEFI PCs because the partitions that precede the OS partition (the EFI, MSR, and if created, the Recovery partitions) normally are not assigned a drive letter in WinPE. The end result is that for UEFI PCs the OS partition in WinPE receives a drive letter of C: because it is the first partition to receive a drive letter. However to ensure that the OS ends up on the C: drive, in the Task Sequence that utilizes the Prestaged Media, the variable OSDPreserveDriveLetter may need to be set to FALSE.


Automate Applying A Task Sequence Prestaged Media On A Hard Drive Via A Task Sequence

The process of applying the Task Sequence Prestaged Media can be automated via a Task Sequence. For ConfigMgr 2012 SP1 and newer, via the variable _SMSTSBootUEFI, one Task Sequence can be used to apply the Prestaged Media on either BIOS or UEFI PCs. The Task Sequence can be a bit difficult to create via a manual step by step process due to the logic involved, so instead of a step by step process describing the creation of the Task Sequence, an exported version of the Task Sequence with all of the steps and logic is provided as a download link below.

It is important to note that when applying the Task Sequence Prestaged Media on a hard drive, it is not a requirement to import the Prestaged Media into the ConfigMgr console. However the Task Sequence in this article uses the Apply Data Image task to apply the Prestaged Media. When using the Apply Data Image task it is required that the Prestaged Media be imported as an Operating System Image in the ConfigMgr console and then distributed to a Distribution Point(s).

If you do not wish to import the Prestaged Media into the ConfigMgr console, instead of using the Apply Data Image task, a Run Command Line task can be used to manually run DISM to apply the Prestaged Media from a predetermined location. The Task Sequence in this article also contains a Run Command Line task that manually applies the Prestaged Media via DISM, but it is disabled by default. Due to the WinPE 3.x boot images of ConfigMgr 2007 missing tools that can manually apply WIM image files (imagex.exe or a version of DISM that supports the /apply-image option), this option is only possible when using ConfigMgr 2012 SP1 or newer. The tools could be added to the WinPE 3.x boot images, but this is beyond the scope of this article.

Please select the method that you would prefer to use:


Apply The Prestaged Media Via The Apply Data Image Task

To use a Task Sequence to automate applying the Prestaged Media on a hard drive via the Apply Data Image task:

  1. Import the Prestaged Media as an Operating System Image. For information on how to do import an Operating System Image see the below links:

  2. Deploy the Prestaged Media from Step 1 to a Distribution Point (DP) that the PC where the Prestaged Media will be applied to has access to.

  3. Download the appropriate exported Task Sequence from the below links:

  4. Import the Task Sequence downloaded in Step 3 into ConfigMgr:

    • System Center 2012 Configuration Manager

      1. To import the task sequence into ConfigMgr 2012, follow the below TechNet documentation:

        How to Manage Task Sequences in Configuration Manager
        How to Export and Import Task Sequences
        To import task sequences



      2. When running the Import Task Sequence Wizard in ConfigMgr 2012 as described in the link in the previous step, at the File Content screen, under the Action column, change Import Failure to Overwrite Ignore Dependency. This will allow you to proceed through the Import Task Sequence Wizard and complete the import of the Task Sequence.

      3. Once the Task Sequence is imported into ConfigMgr 2012, right click on the Task Sequence and choose Edit. You will receive the following message:

        The objects referenced in the task sequence cannot be found. Verify that the object exists and that the task sequence references the correct object name and location.

        Apply Prestaged Media via Apply Data Image task


        Click on the OK button to continue.

    • System Center Configuration Manager 2007

      1. To import the task sequence into ConfigMgr 2007, follow the below TechNet documentation:

        How to Copy a Task Sequence from one Configuration Manager 2007 Site to Another
        http://technet.microsoft.com/en-us/library/bb632642.aspx
        (Follow Steps 6 - 11)

      2. When importing the Task Sequence in ConfigMgr 2007, an Error Reference dialog box will appear with the message:

        This task sequence object references one or more invalid packages. Do you want to edit it?

        Click on the Yes button.

  5. The Task Sequence should automatically open to the Apply Prestaged Media via Apply Data Image task. If it does not do so, make sure to click on the Apply Prestaged Media via Apply Data Image task task.

  6. Under the Apply Prestaged Media via Apply Data Image task, next to Image package:, click on the Browse... button and choose the Prestaged Media that was imported in Step 1.

  7. For ConfigMgr 2012 SP1 and newer, by default the Task Sequence is configured for a partitioning scheme that does not create a Recovery partition for UEFI PCs. If a Recovery partition is desired, follow the below steps. Please note that the Recovery partition is optional and not required for UEFI PCs.

    If a Recovery partition is not desired for UEFI PCs or if only deploying to BIOS PCs, please skip to Step 8.

    1. Click on the Without Recovery Partition group, click on the Options tab, and then click the option Disable this step. This should disable the Without Recovery Partition group.

    2. Click on the With Recovery Partition group, click on the Options tab, and then uncheck the option Disable this step. This should enable the With Recovery Partition group.

  8. Click on the OK button to save the Task Sequence.

  9. Right click on the Task Sequence and choose Properties.

  10. In the Task Sequence Properties window, click on the Advanced tab. In the Advanced tab:

    • Click the option Use a boot image: so that it is checked.

    • Under Use a boot image:, click on the Browse... button and select a boot image from the ConfigMgr environment. Please note that for UEFI PCs the architecture of the boot image has to match the architecture of the PC.

  11. Click on the OK button in the Task Sequence Properties window.

  12. Deploy and run the Task Sequence to the PC where the Prestaged Media needs to be applied to.

  13. Once the Task Sequence is complete, the PC will shut down automatically.

Unless testing to make sure the Prestaged Media works, DO NOT turn the PC back on after Step 13 or else the Task Sequence will need to be rerun on the PC. A this point the Task Sequence Prestaged Media file has been successfully applied to the hard drive of the PC and the boot partition has been properly prepared to be booted from the Prestaged Media. The hard drive should be ready for delivery to the OEM.


Apply The Prestaged Media Via The Run Command Line Task
(ConfigMgr 2012 SP1 or newer only)

To use a Task Sequence to automate applying the Prestaged Media on a hard drive via the Run Command Line task:

1. Download the exported ConfigMgr 2012 Task Sequence from the below link:

 ConfigMgr 2012 Task Sequence to apply Prestaged Media to multi-partitioned BIOS & UEFI PCs

ConfigMgr 2012 saves exported Task Sequence as ZIP files. Clicking on the above link should download the file automatically.

2. Import the Task Sequence downloaded in Step 1 into ConfigMgr. This should create a new Task Sequence called Apply Prestaged Media on BIOS & UEFI PCs - CM12. For information on how to import a Task Sequence see the below links:

How to Manage Task Sequences in Configuration Manager
How to Export and Import Task Sequences
To import task sequences

http://technet.microsoft.com/en-us/library/hh273490.aspx#BKMK_ExportImport

3. When running the Import Task Sequence Wizard in ConfigMgr 2012 as described in the link in the previous step, at the File Content screen, under the Action column, change Import Failure to Overwrite Ignore Dependency. This will allow you to proceed through the Import Task Sequence Wizard and complete the import of the Task Sequence.

4. After the Task Sequence has been imported, right click on the Apply Prestaged Media on BIOS & UEFI PCs - CM12 Task Sequence and choose Properties.

5. In the Task Sequence Properties window, click on the Advanced tab. In the Advanced tab:

  • Make sure that the option Use a boot image: is checked.

  • Under Use a boot image:, click on the Browse... button and select a boot image from the ConfigMgr environment. Please note that for UEFI PCs the architecture of the boot image has to match the architecture of the PC.

6. Click on the OK button in the Task Sequence Properties window.

7. Right click on the Task Sequence and choose Edit. You will receive the following message:

The objects referenced in the task sequence cannot be found. Verify that the object exists and that the task sequence references the correct object name and location.

Apply Prestaged Media via Apply Data Image task


Click on the OK button to continue.

8. The Task Sequence should automatically open to the Apply Prestaged Media via Apply Data Image task. If it does not do so, make sure to click on the Apply Prestaged Media via Apply Data Image task task.

9. Under the Apply Prestaged Media via Apply Data Image task task, click on the Options tab, and then click on the Disable this step option. This will disable the Apply Prestaged Media via Apply Data Image task task.

10. Click on the Apply Prestaged Media via Run Command Line task group, click on the Options tab, and then uncheck the Disable this step option. This will enable the Apply Prestaged Media via Run Command Line task group.

11. Under the Apply Prestaged Media via Run Command Line task group, click on the Connect to Network Folder task:
  • Configure the Path: field so that it points to the UNC path where the Prestaged Media is located.

  • Configure the Account: field so that it has the proper credentials to connect to the UNC path in the Path: field.

Please note that if you plan to have the Prestaged Media on a local drive such as a USB Flash Drive, this task can be disabled by clicking on the Options tab, and then clicking on the Disable this step option

12. Click on the Apply Prestaged Media task. In the DISM command under the Command line: box, next to /ImageFile:, replace prestaged_media_file.wim with the correct the path and name for the Prestaged Media WIM file. If using a network path, the path can be determined based on the settings of the Connect to Network Folder task in Step 11. When modifying the path in the DISM command, please make sure there is not a space between the /ImageFile: option and the path to the Prestaged Media file.

13. By default the Task Sequence is configured for a partitioning scheme that does not create a Recovery partition for UEFI PCs. If a Recovery partition is desired, follow the below steps. Please note that the Recovery partition is optional and not required for UEFI PCs.

If a Recovery partition is not desired for UEFI PCs or if only deploying to BIOS PCs, please skip to Step 14.

a. Click on the Without Recovery Partition group, click on the Options tab, and then click the option Disable this step. This will disable the Without Recovery Partition group.

b. Click on the With Recovery Partition group, click on the Options tab, and then uncheck the option Disable this step. This will enable the With Recovery Partition group.

14. Click on the OK button to save the Task Sequence.

15. Deploy and run the Task Sequence to the PC where the Prestaged Media needs to be applied to.

16. Once the Task Sequence is complete, the PC will shut down automatically.

Unless testing to make sure the Prestaged Media works, DO NOT turn the PC back on after Step 16 or else the Task Sequence will need to be rerun on the PC. A this point the Task Sequence Prestaged Media file has been successfully applied to the hard drive of the PC and the boot partition has been properly prepared to be booted from the Prestaged Media. The hard drive should be ready for delivery to the OEM.

Please note that in Step 12, a local drive, such as a USB Flash Drive, can be used instead of a network drive. This approach would not require the Connect to Network Folder task. However the main challenge with this approach is determining what the drive letter of the local drive will be in WinPE so that the path to the Prestaged Media can be properly modified in Step 12.


Considerations For The Task Sequence That Utilizes The Prestaged Media

  1. If the Task Sequence being used to deploy the Prestaged Media is being used for other scenarios besides Prestaged Media or with PCs that have different partitioning schemes (BIOS vs. UEFI), you may need to have multiple Apply Operating System tasks with conditions that account for each different scenarios. For example:

    1. When deploying Prestaged Media on BIOS PCs, you may need to configure the following in the Apply Operating System task:

      • In the Options tab, create a condition where the Task Sequence variable _SMSTSMediaType equals OEMMedia

      • In the Options tab, create a condition where the Task Sequence variable _SMSTSBootUEFI not equals TRUE (only applicable in ConfigMgr 2012 SP1 or newer)

      • In the Properties tab, under Select the location where you want to apply this operating system, set the following values:

        • Destination: Specific disk and partition
        • Disk: 0
        • Partition: 2

    2. When deploying Prestaged Media on UEFI PCs (only applicable in ConfigMgr 2012 SP1 or newer), you may need to configure the following in the Apply Operating System task:

      • In the Options tab, create a condition where theTask Sequence variable _SMSTSMediaType equals OEMMedia

      • In the Options tab, create a condition where the Task Sequence variable _SMSTSBootUEFI equals TRUE

      • In the Properties tab, under Select the location where you want to apply this operating system, set the following values:

        • Destination: Specific disk and partition
        • Disk: 0
        • Partition: 3 (no Recovery partition present) or Partition: 4 (Recovery partition present)

  2. In ConfigMgr 2012 SP1 or newer, if applying the solution in Step 13 - 23 for BIOS PCs which guarantees that the OS is applied to drive letter C:, in the Task Sequence that utilizes the Prestaged Media, make sure to add a Set Task Sequence Variable task immediately before the Apply Operating System task that sets the variable OSDPreserveDriveLetter to FALSE. This may need to be done for both BIOS and UEFI PCs to ensure that the OS ends up on drive letter C:.

  3. If the Task Sequence being used to deploy the Prestaged Media is also used for scenarios other than Prestaged Media, there may be Format and Partition Disk tasks in the Task Sequence. Formatting the disk in Prestaged Media scenarios will cause the contents of the Prestaged Media to be lost which would cause the Task Sequence to fail. To prevent this, make sure that there is a condition on all of the Format and Partition Disk tasks in the Task Sequence where the Task Sequence variable SMSTSMediaType not equals OEMMedia. This will prevent the disk from being formatted in Prestaged Media scenarios.


Delivery Of Prestaged Media To OEM

After each of the above methods describing how to apply Prestaged Media, there is a note pointing out to make sure not to turn the computer back on once the process is complete. At this point, normally the hard drive is pulled from the PC and delivered to the OEM. The OEM then duplicates the hard drive and makes an image of it. The OEM then applies the image to all PCs shipped from them to the end customer.

However, instead of delivering a physical hard drive to the OEM, Stand-alone Media containing the Prestaged Media and the Task Sequence from this article can be delivered to the OEM. The OEM could then run the Stand-alone media on one of the model PCs, pull the hard drive themselves, and perform any additional disk duplication and image creation that is part of their process.

To accomplish this, make sure to follow the Apply The Prestaged Media Via The Apply Data Image Task section and then after Step 11, instead of running the Task Sequence locally, create Stand-alone media. The Stand-alone media can then be delivered to the OEM.

Instructions on how to create Stand-alone media are in the below TechNet articles:

System Center Configuration Manager 2007
How to Create Stand-alone Media
http://technet.microsoft.com/en-us/library/bb632784.aspx

System Center 2012 Configuration Manager
How to Deploy Operating Systems by Using Media in Configuration Manager
How to Create Stand-alone Media
http://technet.microsoft.com/en-us/library/79465d90-4831-4872-96c2-2062d80f5583#BKMK_CreateStandAloneMedia


Wilhelm Kocher
Senior PFE - EMEA

Steve Rachui
Senior PFE - US

Frank Rojas
Senior Support Escalation Engineer

Attachment: Apply Prestaged Media for BIOS and UEFI PCs - CM12.zip
Comments
  • Fantastic post guys, this is awesome.
    I've picked up a minor error in the downloadable task sequence. The step called 'Run DiskPart Script to Assign EFI Partiton S:' is missing the windows directory in the path, it is currently set to x:\system32\diskpart.exe.
    I'm also getting Windows Boot Manager error 0xc000000e on first boot after applying the prestaged media via the offline media method. Will keep testing to diagnose the cause.

  • Thank you for the catch Peter. I have replaced the downloadable Task Sequence with a corrected one. Please let me know how your stand-alone media works. I actually never specifically tested this scenario and just assumed it would work. I will test when I get a chance.

  • Excellent! Successfully deployed to a test Surface Pro and to a Surface Pro 2...I have been beating my head against the wall trying to get pre-staged media ready for our hardware vendor for a large order of Surface Pro 2 devices for physicians. Your sequence has saved our deployment engineers many hours of manually booting from USB drives...

  • Thanks for this article! Though not sure I understand.
    We have a recovery partition and a OS partition, is this the only way to apply the image to the harddisk? I seem to be able to format the disk in 2 partitions, then applying the prestaged image to volume 2. Only thing is it assigned a driveletter to recovery partition. We do not want the recovery partition to be assigned a driveletter.

  • Hi Peter...did you find a fix to the 0xc000000e error? I am seeign the same issue.

  • I ran into one problem with the directions for including a recovery partition in the UEFI situation. When I tried to run "Attributes Volume Set NoDefaultDrive Letter", I got an error:

    Virtual Disk Service Error:
    The object is not found

    I found that after running the Set ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac" command, the volume was marked as hidden, which seems to be what caused this error. I was able to get around the issue by putting the Attributes command before the set ID command, as shown below:

    Create Partition Primary Size=300
    Format FS=NTFS Label=Recovery Quick Override
    Attributes Volume Set NoDefaultDriveLetter
    Set ID="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    GPT Attributes=0x8000000000000001

  • Frank - did you ever get a chance to test the method for UEFI systems?
    I'm also getting the Windows Boot Manager error 0xc000000e when I boot a machine that has had the prestaged image applied using the UEFI steps listed. I have used the BIOS steps successfully on another machine.

  • We have tested the methods described in this article with images in the Prestaged media built using the following methods:

    1) Captured Windows OS WIM created on a UEFI PC via a Build and Capture Task Sequence from source files (Operating System Installer)
    2) Captured Windows OS WIM created on a BIOS PC via a Build and Capture Task Sequence from source files (Operating System Installer)
    3) Captured Windows OS WIM created on a UEFI PC via a Build and Capture Task Sequence from Install.wim (Operating System Image)
    4) Captured Windows OS WIM created on a BIOS PC via a Build and Capture Task Sequence from Install.wim (Operating System Image)
    5) Install.wim from source files via an Operating System Image

    in PCs with the following configurations:

    1) BIOS PC
    2) UEFI PC with SecureBoot enabled
    3) UEFI PC with SecureBoot disabled

    In each scenario, the test was successful and worked. I cannot say what is causing error 0xc000000e, but I would recommend opening a support case if you do continue having the issue.

  • Frank - Does the WIM need to be captured from a UEFI PC to be deployed to a UEFI system? Or can a reference image created on a gen1 VM or a bios based PC be applied to a UEFI based PC without issue?

    I was trying to use the same MDT integrated task sequence and wim that I use for BIOS based PC's, but even if that were an issue, I don't think it explains the 0xc000000e error I'm seeing. The error comes up on first boot after applying the pre-staged image, when the PC should be booting to WinPE the first time, before it even downloads the task sequence from the sccm server...

  • I've also created a thread on the technet forums in hopes of finding a solution to this issue. I created a batch script that runs all the steps to apply the prestaged image to a UEFI based PC, so that I could reproduce the results after having tested the process. I have included the script and related text files in the forum post, just in case I made an error somewhere in the process.
    http://social.technet.microsoft.com/Forums/en-US/25b11473-e76c-4ef6-a556-6795547431c5/apply-prestaged-media-to-uefi-pc-windows-boot-manager-error-0xc000000e-on-first-boot?forum=configmanagerosd

  • You do not have to build the image on UEFI PC for it to work on UEFI PC. It can be built on a BIOS PC and it will work on a UEFI PC (and the vice-versa is also true). In my test matrix above, all 5 different images were deployed on the 3 different PC configurations (for a total of 15 tests) and they all worked. I have also used this method with several customers and it also worked for them.

    Error 0xc000000e is either:

    STATUS_NO_SUCH_DEVICE
    A device which does not exist was specified.

    or

    ERROR_OUTOFMEMORY
    Not enough storage is available to complete this operation.

    This makes me believe that there may be something wrong with the configuration of the BCD Store. You mentioned that you made the Recovery Partition not hidden. According to the TechNet documentation that I used that helped create this article, the partition needs to be hidden. Is there a reason you are unhiding it? Also does the process work when you don't try to create a Recovery Partition?

  • I agree that the issue seems like a problem with the BCD store. Unfortunately, I'm not having much luck finding info on how to determine exactly what the issue might be.

    I didn't make the recovery partition 'not hidden', I just had to run the "Attributes Volume Set NoDefaultDriveLetter" step before it became hidden or it wouldn't apply.

    I did subsequently try the process without creating the recovery partition, and still got the same 0xc000000e error on boot after the prestage media image was applied.

  • I am not sure what is causing the problem. All I can suggest at this point is opening a case so we can do some in depth troubleshooting. Thanks.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment