You are here:   Research
  |  Login

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

Minimize
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.

Prerequisites

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.

D:\Setup\WinPE50_x64
D:\Setup\WinPE50_ExtraFiles
D:\Setup\WinPE50_Drivers\amd64
D:\Mount

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..."
    Break
}

# Delete existing WinPE build folder (if exist)
try 
{
if (Test-Path -path $WinPE_BuildFolder) {Remove-Item -Path $WinPE_BuildFolder -Recurse -ErrorAction Stop}
}
catch
{
    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"
    Break
}

# 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\WinPE-Scripting.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\WinPE-Scripting_en-us.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\WinPE-WMI.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\WinPE-WMI_en-us.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\WinPE-HTA.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\WinPE-HTA_en-us.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\WinPE-MDAC.cab
& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\en-us\WinPE-MDAC_en-us.cab

# 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\Toolsx64.cab" -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

Minimize




Where you can meet us!

Live Stream Recordings
ConfigMgr 1806 and W10 OSD

Windows 10 OSD Classes (US)
Dec 10, 2018, Chicago, US

Windows 10 OSD Classes (Europe)

Feb 4, 2019, Culemborg, The Netherlands

ConfigMgr CB Classes (US)
Jan 21, 2019, New York, US

Video-based trainings
https://online.truesec.com
https://deploymentartist.com/Training/Videos

MDT, Windows 10 and ConfigMgr Books
http://deploymentartist.com/Books

Contact Info
http://deploymentresearch.com/theteam