Problem including PowerShell into Windows 11 22H2 boot.wim

ubunonymount

New Member
Hello,

I'm trying to include powershell into the windows 11 setup boot.wim image (flag 2).
Unfortunately I get an error with most packages: "Package is not applicable to this image."

I got the windows ISO image from microsoft using MediaCreationTool
https://www.microsoft.com/en-us/software-download/windows11

And I got the powershell (and other) .cab packages from Windows PE add-on for the Windows ADK
https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install
C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs

So everything (iso image and cab files) must be up-to-date.

What am I doing wrong?

Thanks!

Screenshot 2023-11-30 023749.jpgScreenshot 2023-11-30 023920.jpg
 
ADK for Windows 11 22H2 (updated September 2023) is actually ADK for Windows Server 23H2, but MS lie

you should use the original ADK for Windows 11 22H2 under Other ADK downloads
 
The 22H2 WinPE ADK is a total mess, it's possible to add those packages except doing so requires a ridiculously stupid dependency order. WTF MS.

WinPE Optional Components (OC) Reference

Doing the math for you:
1701323162469.png

Everything does integrate except for two packages, which are actually reserved for WinRE (not WinPE). For some reason, you can't do WinPE-NetFX-[localization] in the same pass as WinPE-NetFX. But it's fine on the next pass.

Update: For those paying close attention, I forgot to snapshot Pass 2. Please follow the chart for the correct sequence.
 

Attachments

  • Windows 10 x64-2023-11-29-21-22-20.png
    Windows 10 x64-2023-11-29-21-22-20.png
    152.5 KB
  • Windows 10 x64-2023-11-29-21-30-02.png
    Windows 10 x64-2023-11-29-21-30-02.png
    102.1 KB
  • Windows 10 x64-2023-11-29-21-48-06.png
    Windows 10 x64-2023-11-29-21-48-06.png
    178.2 KB
Last edited:
you should use the original ADK for Windows 11 22H2 under Other ADK downloads

I did use the original 22H2 add-on!
Verified: Signed
Signing date: 3:36 AM 5/7/2022
Publisher: Microsoft Corporation
Company: Microsoft Corporation
Description: Windows Assessment and Deployment Kit Windows Preinstallation Environment Add-ons
Product: Windows Assessment and Deployment Kit Windows Preinstallation Environment Add-ons
Prod version: 10.1.22621.1
File version: 10.1.22621.1
MachineType: 32-bit
 
I agree it's a mess on multiple fronts.

What I don't understand is using the 22621 ADK, you're forced to do 4 integration passes. I recall in the older W10 builds, you only needed something like 2-3 passes to add all the PS or WMI OC's.
 
The 22H2 WinPE ADK is a total mess, it's possible to add those packages except doing so requires a ridiculously stupid dependency order. WTF MS.

WinPE Optional Components (OC) Reference

Doing the math for you:
View attachment 10820

Everything does integrate except for two packages, which are actually reserved for WinRE (not WinPE). For some reason, you can't do WinPE-NetFX-[localization] in the same pass as WinPE-NetFX. But it's fine on the next pass.

Update: For those paying close attention, I forgot to snapshot Pass 2. Please follow the chart for the correct sequence.
Thank you for your help.
I made progress with your suggestion.

I downloaded and installed the "Windows PE add-on for the ADK for Windows 11, version 22H2" which is located under "Other ADK downloads".

1701398354490.png


Now some packages are working without error.

Pass 1 works with your solution, but I'm stuck at Pass 2.
I can't apply "WinPE-NetFX" package.

1701397382673.png

In the queue it's listed.
But in apply tab its missing.

1701397451021.png

It's not telling me any kind of error message or else.
It's just like it doesn't exists or if NTLite can't find NetFx package.
WinPE-NetFx_en-US package could be found, but can't be installed as long as WinPE-NetFx is not installed.

1701397562760.png

Do you have any idea why NTLite behaves like that?
Shouldn't I get at least some kind of error message instead of just dropping the package from the list?
 
Do you have any idea why NTLite behaves like that?
Shouldn't I get at least some kind of error message instead of just dropping the package from the list?
DISM (which does the integration) is rejecting some packages, because of dependency checks.

1. There is no point adding KB5027397 Enablement Package.
This update enables 23H2 Features if you're on normal Windows, but WinPE is missing the Desktop. So why bother?​

2. Follow this package order:

Pass 1
[Fonts]​
WinPE-Scripting​
WinPE-WMI​
WinPE-Scripting_en-us​
WinPE-WMI_en-us​
Pass 2
WinPE-HTA​
WinPE-SecureStartup​
WinPE-HTA_en-us​
WinPE-SecureStartup_en-us​
WinPE-NetFx​
Pass 3
WinPE-PlatformId​
WinPE-PowerShell​
WinPE-NetFx_en-us​
WinPE-PowerShell_en-us​
Pass 4
All other packages, except for WinRE features​
 
DISM (which does the integration) is rejecting some packages, because of dependency checks.

1. There is no point adding KB5027397 Enablement Package.
This update enables 23H2 Features if you're on normal Windows, but WinPE is missing the Desktop. So why bother?​

2. Follow this package order:

Pass 1
[Fonts]​
WinPE-Scripting​
WinPE-WMI​
WinPE-Scripting_en-us​
WinPE-WMI_en-us​
Pass 2
WinPE-HTA​
WinPE-SecureStartup​
WinPE-HTA_en-us​
WinPE-SecureStartup_en-us​
WinPE-NetFx​
Pass 3
WinPE-PlatformId​
WinPE-PowerShell​
WinPE-NetFx_en-us​
WinPE-PowerShell_en-us​
Pass 4
All other packages, except for WinRE features​
Thank you for your reply.

I did not install KB5027397, it must come preinstalled when downloading official image from microsoft:
https://www.microsoft.com/en-us/software-download/windows11

Unfortunately the package order which you suggest me to follow does not work.
I'm stuck at Pass 2 with "WinPE-NetFx" package.
I can add the package to update queue, but when I click on "apply" it's gone and no error message, it's just not showing anymore.

Would you suggest me to try it with an older Windows11.iso file? And how do I get an older version from the official microsoft website?
Thank you very much and sorry for the stupid questions, I'm kind of new to windows ADK and DISM stuff...


Pass 1: (works without problem at all)

1701455907469.png


Pass 2: (everthing passed, but WinPE-NetFx got lost)
Update queue:

1701456412099.png
Apply:
1701456619015.png
 
After some testing, I understand the problem better.

When using 22621 ADK, NTLite skips over NetFX when applied to 23H2 boot.wim. But 22H2 boot.wim has no issues.
25398 ADK doesn't work on 23H2 boot.wim, as you already know.

What I would do is switch out the boot.wim on 23H2 ISO with the 22H2 version, which we know does integrate the OC's fine. I don't think for the purpose of software installation, there's many differences between them.
 
After some testing, I understand the problem better.

When using 22621 ADK, NTLite skips over NetFX when applied to 23H2 boot.wim. But 22H2 boot.wim has no issues.
25398 ADK doesn't work on 23H2 boot.wim, as you already know.

What I would do is switch out the boot.wim on 23H2 ISO with the 22H2 version, which we know does integrate the OC's fine. I don't think for the purpose of software installation, there's many differences between them.
Hello garlin,

thank you very much for your research!
Okay, so I will try to switch out the boot.wim with an older version (22H2).

But I'm not quiet sure if this will work:
  1. It is very important to me to obtain the images only from official sources. How do I get an official Windows 11 ISO with boot.wim 22H2 version? I guess Microsoft only allows download of the current version 23H2 and not the older versions.

  2. As I have written at the beginning of this thread, I need the boot.wim for Windows Installation Setup purpose (bootflag 2) and not just as Windows PE (bootflag 9). Is it possible to just switch out different boot.wim's from different ISO images or could this end up corrupting the windows installation?
My goal is to have a Windows Installation (boot.wim flag 2) where I can run interactive powershell scripts with user interactions.

Thank you very much and sorry for taking so much time from you!
good night!
 
1. If you're restricted to downloading from official MS sources, there is a PS script for running older Media Creation Tool versions. While AveYo has written a better known MCT Wrapper, this script is shorter and much easier to audit the contents.

https://www.ntlite.com/community/index.php?threads/trouble-finding-w10-21h2-iso.3602/post-35637

2. boot.wim (WinPE) and (Setup) are basically identical, except the latter includes the Setup files. If you apply the ADK's Setup OC packages to WinPE, you will get WinPE Setup as the final product.

3. You can't run custom scripts in the default WinPE Setup, without overwriting one or more WinPE startup files. When WinPE detects the presence of Setup.exe file, it will directly run the app.

Either you replace Setup\CmdLine in the registry (brute force), or rename sources\setup.exe inside the boot.wim to another name, and call the renamed setup.exe from your script.

https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/
 
Hello garlin,

thank you very much for your help! :D

1. If you're restricted to downloading from official MS sources, there is a PS script for running older Media Creation Tool versions. While AveYo has written a better known MCT Wrapper, this script is shorter and much easier to audit the contents.

https://www.ntlite.com/community/index.php?threads/trouble-finding-w10-21h2-iso.3602/post-35637
Wow, thank you so much! This is the one I'm searching for!https://www.ntlite.com/community/index.php?threads/trouble-finding-w10-21h2-iso.3602/post-35637
2. boot.wim (WinPE) and (Setup) are basically identical, except the latter includes the Setup files. If you apply the ADK's Setup OC packages to WinPE, you will get WinPE Setup as the final product.
Ahh, okay, thank you, I will try that out!
3. You can't run custom scripts in the default WinPE Setup, without overwriting one or more WinPE startup files. When WinPE detects the presence of Setup.exe file, it will directly run the app.

Either you replace Setup\CmdLine in the registry (brute force), or rename sources\setup.exe inside the boot.wim to another name, and call the renamed setup.exe from your script.

https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/
Yeah, I'm planning to start the scripts using an autounattend.xml file kind of like that:
XML:
(...)
<settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Path>powershell.exe -File "C:\Scripts\Script_1.ps1"</Path>
                </RunSynchronousCommand>
                <RunSynchronousCommand wcm:action="add">
                    <Order>2</Order>
                    <Path>powershell.exe -File "C:\Scripts\Script_2.ps1"</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
(...)
 
Hello garlin,

unfortunately it's not working either, even with 22H2 iso. :confused:
I don't understand what I'm doing wrong, because you said on your workstation the integration of powershell works just fine.
Maybe there is something not okay with my computer or my operating system, I will try it tomorrow on a different machine.
I'm using the 22H2 (10.0.22621.1702) iso-image from the batch script from your post:

C:\Users\Windows11\Downloads>MCTWrapper.bat W11_22H2
1. If you're restricted to downloading from official MS sources, there is a PS script for running older Media Creation Tool versions. While AveYo has written a better known MCT Wrapper, this script is shorter and much easier to audit the contents.
https://www.ntlite.com/community/index.php?threads/trouble-finding-w10-21h2-iso.3602/post-35637

For the ADK I'm using the "Windows PE add-on for the ADK for Windows 11, version 22H2" (10.0.22621.1):
https://go.microsoft.com/fwlink/?linkid=2196224
1701573703811.png

NTLite: Version: 2023.11.9515 (64-bit)

My Hardware:
OS NameMicrosoft Windows 11 Pro
Version10.0.22631 Build 22631
System Typex64-based PC
ProcessorAMD Ryzen Threadripper PRO 5955WX 16-Cores, 4001 Mhz, 16 Core(s), 32 Logical Processor(s)
BIOS Version/DateAmerican Megatrends International, LLC. 7.05, 27.03.2023
BIOS ModeUEFI
BaseBoard ManufacturerASRock
BaseBoard ProductWRX80 Creator
Platform RoleWorkstation
Secure Boot StateOff
LocaleGermany
Hardware Abstraction LayerVersion = "10.0.22621.2506"
Time ZoneW. Europe Standard Time
Installed Physical Memory (RAM)128 GB
Total Physical Memory128 GB
Available Physical Memory107 GB
Total Virtual Memory145 GB
Available Virtual Memory49,8 GB
Page File Space17,0 GB
Page FileD:\pagefile.sys
Kernel DMA ProtectionOff
Virtualization-based securityRunning


When using 22621 ADK, NTLite skips over NetFX when applied to 23H2 boot.wim. But 22H2 boot.wim has no issues.

Still skipping NetFX, even with 22H2....
1701573941048.png
1701574070984.png

1701574142674.png
 
Back
Top