You are here:   Research
  |  Login

Welcome to my blog, quickest way to find articles is usually to search for them.

Search in All Title Contents

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

Dec 15 2013

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:\Setup\WinPE50_x64"
$WinPE_ExtraFiles = "D:\Setup\WinPE50_ExtraFiles"
$WinPE_Architecture = "amd64" # Or x86
$WinPE_Drivers = "D:\Setup\WinPE50_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 Kits\8.1\Assessment and Deployment Kit"
$WinPE_ADK_Path = $ADK_Path + "\Windows Preinstallation Environment"
$WinPE_OCs_Path = $WinPE_ADK_Path + "\$WinPE_Architecture\WinPE_OCs"
$DISM_Path = $ADK_Path + "\Deployment Tools" + "\$WinPE_Architecture\DISM"

# 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_Architecture\en-us\winpe.wim" "$WinPE_BuildFolder"

# Mount the WinPE image
$WimFile = "$WinPE_BuildFolder\winpe.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_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\

# Install WinPE 5.0 Drivers (using ADK 8.1 version of dism.exe instead of Add-WindowsDriver)
& $DISM_Path\dism.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 Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\" -F:*.* $WinPE_MountFolder
Copy-Item "C:\Program Files\Microsoft Deployment Toolkit\Templates\DartConfig8.dat" $WinPE_MountFolder\Windows\System32\DartConfig.dat

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

Deployment News

Happy deployment, and thanks for reading!

What our lawyers makes us say:

This information is provided "AS IS" with no warranties, confers no rights and is not supported by the authors or Deployment Artist.

Copyright © 2017 by Deployment Artist (the company behind deployment research). All rights reserved. No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

Shorthand: Don't pass off our work as yours, it's not nice.

Blog Archive


Where you can meet us!

Live Stream Recordings
ConfigMgr 1806 and W10 OSD

5 Days - Mega Geek Week 
(multiple classes, ConfigMgr, OSD etc.)
- Johan Arwidmark, Mikael Nystrom...
Jun 10, 2019, Chicago, IL, US

4 Days - Windows 10 OSD Classes
- Johan Arwidmark
May 20, 2019, San Diego, CA, US
Jun 17, 2019, Culemborg, NL
Jul 8, 2019, Phoenix, AZ, US

5 days - ConfigMgr Classes
- Johan Arwidmark and Kent Agerlund
Apr 8, 2019, Chicago, IL, US
Apr 22, 2019, Houston, TX, US

Video-based trainings

MDT, Windows 10 and ConfigMgr Books

Contact Info