Adding PowerShell 7 to WinPE

While not officially supported, PowerShell 7 seems to play well with WinPE. Here is a short script that adds PowerShell 7.4 to WinPE 11. In this update, I tested adding PowerShell 7.4.13 to Windows ADK for Windows 11 24H2 (Build 26100).

Update January 4, 2026: Verified support for PowerShell 7.4 and moved the script to GitHub.

Note: While PowerShell 7.4 is not the latest stable release, it's currently the latest Long-Term Support (LTS) release, built on .NET 8, which I recommend for WinPE. The upcoming 7.6 version will be the next LTS release, built on .NET 10. LTS releases are supported for three years.

Download PowerShell 7

First, download the ZIP version of the latest PowerShell 7.4, at the time of writing this blog post it was 7.4.13: https://github.com/PowerShell/PowerShell/releases. For this example, I downloaded PowerShell-7.2.5-win-x64.zip and saved it in my C:\Setup folder.

Adding PowerShell 7 to WinPE using PowerShell

Here is the script that adds PowerShell 7 (and some other components to WinPE) as well as sets the environment variables for it: https://github.com/DeploymentResearch/DRFiles/blob/master/Scripts/WinPE/Add-PowerShell7.ps1

About the author

Johan Arwidmark

5 5 votes
Article Rating
Subscribe
Notify of
guest
23 Comments
Newest
Oldest Most Voted
Eric
Eric
1 year ago

Newer versions of Powershell 7 require additional files (ICU*.dll).
You might want to update your script.

Eric
Eric
9 months ago

I'm referring to Powershell v7.5.x

In my own testing, I've noticed that to make Powershell 7.5.x work in WinPE11, you need to add the following files from a Win11 OS to the WIM file:
  \Windows\System32\icu.dll
  \Windows\System32\icuin.dll
  \Windows\System32\icuuc.dll
  \Windows\Globalization\ICU\*.*
  
# This prevents the error "Could not load ICU data. UErrorCode: 2"

Last edited 9 months ago by Eric
Alexander
Alexander
2 years ago

Observed with PowerShell 7.4.5 and Windows PE from the may 2024 Windows ADK (10.1.26000.1). I ran into an issue with "Get-PhysicalDisk" cmdlet in PowerShell 7.4.5 under WinPE. It fails under PowerShell 7.4.5, but works under Windows PowerShell 5.1. As far as I can see, there are two versions of the CimCmdlets modules: version 1.0.0.0 in "%windir%\System32\WindowsPowerShell\v1.0\Modules", that works under Windows PE. version 7.0.0.0 in "%ProgramFiles%\PowerShell\7\Modules" that will not work under WinPE. If you run "Get-Module -ListAvailable -All" under the PowerShell 7, you will see that the 1.0.0.0 version of CimCmdlets is marked for PSEdition Desk, and that the 7.0.0.0 module… Read more »

Koen
Koen
2 years ago

Hi Johan,
Can you use the Get-ComputerInfo command in powershell?

Matt
Matt
2 years ago

This script works with arm64 architecture as well. I tested with the May 2024 ADK and WinPE.

However, to get a bootable ISO, you need to copy the AMD64 version of etfsboot.com from "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\etfsboot.com" to the same directory for arm64.

It is probably also a good idea to include the optional components WinPE-x64-Support.cab and WinPE-x64-Support_en-us.cab as well.

Clément
Clément
2 years ago

Hi, thanks for this script which run without any error.
But once I modified my winpe (I extracted boot.wim from the created ISO, and put it in the windows PE kit, to be used by MDT), I can't create a capture image from boot image with powershell 7. When trying with old boot image, no problem.
Error is : The Windows Deployment Service Image Capture Wizard was not found in the specified Windows PE Image
Thanks

Clément
Clément
2 years ago

Thanks for all of your scripts. I upgraded my way to do capture, by fully using MDT now. And no problems at all.

Walter LaGroe
3 years ago

$devDetail = (Get-CimInstance -CimSession $session -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND ParentID='./DevDetail'")

..to get HardwareHashes, does not work..

Dennis
Dennis
3 years ago

How do i use this script?
It wont run as an ps1 or as a cmd file?

it spits out errors on your Variables in the script.

I have used the guide from Microsoft for the Powershell 1.0, so that part works, but i would like to have 7 now, and get rid of the notice for Updates.

The Microsoft-way works.
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-adding-powershell-support-to-windows-pe?view=windows-11

Dan
Dan
4 years ago

I tried it and it works. But too bad it's working only if original powershell is integrated.

Dan
Dan
4 years ago

Get-Disk, Clear-Disk, New-Partition, Get-Partition. Also, Get-Counter (unable to load pdh.dll or one of its dependencies). Probably there are more. But I think I know why. If I don't integrate powershell 5.0, the environment variable path is missing the path to c:Windows\System32\WindowsPowerShell\v1.0.

Ribamar
Ribamar
3 years ago
Reply to  Dan

Missing WinPE-Scripting.cab, WinPE-Scripting_en-us.cab, WinPE-StorageWMI.cab and WinPE-StorageWMI_en-us.cab to make disk commands work


>