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:
- 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.
- 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:
The following instructions apply to BIOS PCs for both ConfigMgr 2007 SP2 R2/R3 and ConfigMgr 2012 SP1 and newer.
- 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
- 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:\. - In the command prompt window, at the X:\ command prompt type in:
DiskPart
This should give the DISKPART> prompt. - 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=S
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:
- 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. - 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. - 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.
- 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 imagex.exe 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
- WinPE 4 or newer boot image (default in ConfigMgr 2012 SP1 and newer)
This step will apply the Prestaged Media to the OS partition and will take a few minutes to complete.
- 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. - 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. - 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:). - 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.
- 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. - 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 - At the X:\ command prompt, type in the following command to open NotePad:
NotePad.exe - 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. - 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.
- Navigate to the following path
- 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.
- Navigate to the following path
- 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-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)
- In NotePad save the changes to the winpeshl.ini file by going to File --> Save.
- Close out of NotePad by going to File --> Exit.
- 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. - At the X:\ command prompt, type in:
rmdir c:\windows\temp\mount /s /q
This will clean up the mount directory by deleting it. - 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.
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.
- 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.
- 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:\. - In the command prompt window, at the X:\ command prompt type in:
DiskPart
This should give the DISKPART> prompt. - 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:.
- 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. - 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. - 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.
- 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. - 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. - 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. - 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:). - 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.
- 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. - 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 - At the X:\ command prompt, type in the following command to open NotePad:
NotePad.exe - 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. - 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.
- 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.
- 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)
- Backs up the contents of the current EFI partition (in case it changed 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
- In NotePad save the changes to the winpeshl.ini file by going to File --> Save.
- Close out of NotePad by going to File --> Exit.
- 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. - At the X:\ command prompt, type in:
rmdir c:\windows\temp\mount /s /q
This will clean up the mount directory by deleting it. - 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 th 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 an Apply Data Image task, the Task Sequence can be modified to use a Run Command Line task to manually run DISM to apply the Prestaged Media from a predetermined location. 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
- Apply The Prestaged Media Via The Run Command Line Task (ConfigMgr 2012 SP1 or newer only)
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:
- Import the Prestaged Media as an Operating System Image. For information on how to do import an Operating System Image see the below links:
System Center 2012 Configuration Manager
How to Manage Operating System Images and Installers in Configuration Manager
How to Add an Operating System Image or Operating System Installer
To add an operating system image
http://technet.microsoft.com/en-us/library/hh397283.aspx#mainBody
System Center Configuration Manager 2007
How to Add Operating System Images
http://technet.microsoft.com/en-us/library/bb633411.aspx - 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.
- Download the appropriate exported Task Sequence from the below links:
- ConfigMgr 2007 Task Sequence to apply Prestaged Media to multi-partitioned BIOS PCs
Since ConfigMgr 2007 saves exported Task Sequence as XML files, and since web browsers display XML files natively, clicking on the above link will only display the XML file in a new windows. To download the above XML file in the above link, right click on the link and choose to download the file. Depending on the web browser being used, this option could be labeled something like Save target as... or Save Link As.... - 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.
- Import the Task Sequence downloaded in Step 3 into ConfigMgr:
- System Center 2012 Configuration Manager
- 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
http://technet.microsoft.com/en-us/library/hh273490.aspx#BKMK_ExportImport - 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.
- 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
- To import the task sequence into ConfigMgr 2012, 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) - 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.
- 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.
- 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.
- 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 9.
- 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.
- 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.
- Click on the OK button to save the Task Sequence.
- Right click on the Task Sequence and choose Properties.
- 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.
- Click on the OK button in the Task Sequence Properties window.
- Deploy and run the Task Sequence to the PC where the Prestaged Media needs to be applied to.
- 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:
- 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. - Import the Task Sequence downloaded in Step 1 into ConfigMgr. 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 - 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.
- After the Task Sequence has been imported, right click on the Task Sequence and choose Properties.
- 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.
- Click on the OK button in the Task Sequence Properties window.
- 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. - 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Click on the OK button to save the Task Sequence.
- Deploy and run the Task Sequence to the PC where the Prestaged Media needs to be applied to.
- 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
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:
- 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
- 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 theTask Sequence variable _SMSTSMediaType equals OEMMedia
- In the Options tab, create a condition where theTask 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)
- In ConfigMgr 2012 SP1 or newer, if applying the solution in Steps 13 - 23 for BIOS PCs which guarantees that the OS is applied to drive letter C:, in the Task Sequence being used to deploy 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:.
- 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.