PowerShell script – Creating a WinPE 5.0 boot image for ConfigMgr 2012 SP1 CU3

To fully support deploying Windows 8.1 using ConfigMgr 2012 SP1 CU3 you need to have a WinPE 5.0 boot image. Here is a PowerShell script that builds one for you. The script adds the needed components as well as inject drivers, add custom files, and optionally, add in the DaRT 8.1 components from MDOP 2013 R2 if you added them to your MDT 2013 deployment share.


The script assumes you have ADK 8.1 installed (on any of it's supported platforms) and that you have the below structure on the D: drive (if you want to use a different folder, simply change the variables in the # Core Settings section of the script.


In the ExtraFiles fold you can store additional files that you want to have added to the boot image, like a custom frontend. If you haven't added DaRT 8.1 to MDT 2013, just comment out the two lines in the # Add DaRT 8.1 to the boot image. section. In the Drivers folder you simply add any extra drivers you want to have added to the boot image.

Note: As you can see in the script I'm calling the ADK 8.1 version of dism.exe instead of Add-WindowsPackage, since I found it more reliable, especially when running ADK 8.1 on other operating systems than Windows 8.1 and Windows Server 2012 R2.

The script

Download the script

# ---------------------------------------------------------------------------
# Purpose: Used to create a WinPE 5.0 boot image for ConfigMgr 2012 SP1 CU3
# Version: 1.1 - December 11, 2013 - Johan Arwidmark
# This script is provided "AS IS" with no warranties, confers no rights and
# is not supported by the authors or Deployment Artist.
# ---------------------------------------------------------------------------

# Core Settings
$WinPE_BuildFolder = "D:SetupWinPE50_x64"
$WinPE_ExtraFiles = "D:SetupWinPE50_ExtraFiles"
$WinPE_Architecture = "amd64" # Or x86
$WinPE_Drivers = "D:SetupWinPE50_Drivers$WinPE_Architecture"
$WinPE_MountFolder = "D:Mount"

# Check for elevation
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator"))
    Write-Warning "Oupps, you need to run this script from an elevated PowerShell prompt!`nPlease start the PowerShell prompt as an Administrator and re-run the script."
    Write-Warning "Aborting script..."

# Delete existing WinPE build folder (if exist)
if (Test-Path -path $WinPE_BuildFolder) {Remove-Item -Path $WinPE_BuildFolder -Recurse -ErrorAction Stop}
    Write-Warning "Oupps, Error: $($_.Exception.Message)"
    Write-Warning "Most common reason is existing WIM still mounted, use ImageX /unmount to clean up and run script again"

# Set paths to WinPE folders and tools
$ADK_Path = "C:Program Files (x86)Windows Kits8.1Assessment and Deployment Kit"
$WinPE_ADK_Path = $ADK_Path + "Windows Preinstallation Environment"
$WinPE_OCs_Path = $WinPE_ADK_Path + "$WinPE_ArchitectureWinPE_OCs"
$DISM_Path = $ADK_Path + "Deployment Tools" + "$WinPE_ArchitectureDISM"

# Make a copy of the WinPE 5.0 boot image from ADK 8.1
if (!(Test-Path -path $WinPE_BuildFolder)) {New-Item $WinPE_BuildFolder -Type Directory}
Copy-Item "$WinPE_ADK_Path$WinPE_Architectureen-uswinpe.wim" "$WinPE_BuildFolder"

# Mount the WinPE image
$WimFile = "$WinPE_BuildFolderwinpe.wim"
Mount-WindowsImage -ImagePath $WimFile -Path $WinPE_MountFolder -Index 1;

# Copy WinPE ExtraFiles
Copy-Item $WinPE_ExtraFiles* $WinPE_MountFolder -Recurse

# Add WinPE 5.0 optional components required for MDT and ConfigMgr (using ADK 8.1 version of dism.exe instead of Add-WindowsPackage)
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_PathWinPE-Scripting.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Pathen-usWinPE-Scripting_en-us.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_PathWinPE-WMI.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Pathen-usWinPE-WMI_en-us.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_PathWinPE-HTA.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Pathen-usWinPE-HTA_en-us.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_PathWinPE-MDAC.cab
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Pathen-usWinPE-MDAC_en-us.cab

# Install WinPE 5.0 Drivers (using ADK 8.1 version of dism.exe instead of Add-WindowsDriver)
& $DISM_Pathdism.exe /Image:$WinPE_MountFolder /Add-Driver /Driver:$WinPE_Drivers /Recurse

# Add DaRT 8.1 to the boot image (comment out if you don't have added DaRT 8.1 to MDT 2013)
expand.exe "C:Program FilesMicrosoft Deployment ToolkitTemplatesDistributionToolsx64Toolsx64.cab" -F:*.* $WinPE_MountFolder
Copy-Item "C:Program FilesMicrosoft Deployment ToolkitTemplatesDartConfig8.dat" $WinPE_MountFolderWindowsSystem32DartConfig.dat

# Unmount the WinPE image and save changes
Dismount-WindowsImage -Path $WinPE_MountFolder -Save
About the author

Johan Arwidmark

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments