A few weeks back I got a question on how to remove applications from a Windows 11 image. Now, obviously you can run a script on any existing Windows 11 installation to remove unwanted applications, and there are plenty of scripts out there doing that. For example, this script: Remove Built-in Windows 11 apps leveraging a Cloud-Sourced reference file – MSEndpointMgr
The above script is very useful when you have a fleet of existing devices, but if you are the person deploying Windows 11, it's way more effective removing them before deploying Windows 11. I mean, installing apps, just to remove them 10 minutes later is really no point. It's better to simply not install them at all.
There are two elegant ways of doing this:
- Remove the apps in the WIM image. This the static method.
- Remove the apps during the WinPE phase of your deployment. This is the dynamic method, since you can remove different depending on deployment criteria such as department, location etc.
Option #1 – Remove the apps in the WIM Image
If you are always removing the same applications from Windows 11, you might was well remove them directly from the WIM Image. In this guide I'm using the OSDBuilder PowerShell module from David Segura.
1. Download a Windows 11 23H2 ISO from Microsoft
2. Install and Import OSDBuilder by running the following PowerShell commands:
# Install and Import OSDBuilder Modules
Install-Module -Name OSD -Force
Install-Module -Name OSDBuilder -Force
Import-Module -Name OSDBuilder
3. Import the Windows 11 media to OSDBuilder by running the following PowerShell commands:
# Specify Windows 11 23H2 ISO path, and edition to work with
$ISO = "C:\ISO\Windows 11 Business Editions x64 23H2 (updated April 2024).iso"
$Edition = "Windows 11 Enterprise"
# Mount the Operating System ISO
Mount-DiskImage -ImagePath $ISO
# Import the media
Import-OSMedia -ImageName $Edition -SkipGrid
4. Specify which Windows 11 applications you want to remove and initiate a build by running the following PowerShell commands:
# Specify AppxPackages to Remove
$TaskName = "Remove Apps From Windows 11 23H2"
New-OSBuildTask -TaskName $TaskName -RemoveAppx
# Create a new OS Build
# Note: Purposely skipping updates for OS and WinPE since the imported media was already updated
New-OSBuild -ByTaskName $TaskName -Execute -SkipComponentCleanup -SkipUpdates


5. You're done, and you find the new build in the OSDBuilder\OSBuilds folder.

Option #2 – Remove the apps during the WinPE phase of your deployment.
If you need to remove different applications depending on how and where you deploy Windows 11 it's better to have a script removing the applications during deployment. There are plenty of script examples on the Internet for doing so online, but not offline, so here is a script you can use:
Simply add this script to a Run PowerShell Script action in your task sequence. Make sure to run it in the WinPE phase, for example before driver injection, and set the PowerShell execution policy to Bypass.

Been using this script, or a variant of it, for a long time now. Simple and brilliant.
The app package names change, and evolve. Anyone using the script should probably know how to modify it.
Hi, I've been referring to your blog for a while and its a lifesaver (as in: I have time for things other than my job) . OSDBuilder is an excellent tool; it can remove those really stubborn apps such as Xbox etc.
I've used it for 24H2 and it removes the apps but they remain visible in the start menu pinned apps. Clicking on them has the annoying habit of re-installing them.
How can the deployment process be modified that can erase all of these pinned apps?
sorry for the very late reply… The only thing I can think of is deploying custom start menu layouts.
Has anyone been successful in using this script in MDT? I tried but did not work and there were no errors too in the TS logs. powershell.exe -Command Set-ExecutionPolicy -Bypass -File "%ScriptRoot%\Remove-UnwantedAppsWindows11offline.ps1"
As long as you run it in the WinPE phase, it should work. Do you get any errors in Remove-UnwantedAppsWindows11offline.log?
Does #1 works for Windows 11 24H2
If not is it possible to get it to work?
I have not tried yet, but it should as long as the app list is updated
Johan have you tried your script with Windows 11 24H2. I've just tried a new build and capture reference build and no apps were uninstalled when running the script within a task sequence step.
Strangely, the step ran successfully (albeit within one second) but no log file was produced. This script worked perfectly and removed apps within my 23H2 B&C task sequence .
I have not (yet)
OSDisk is the environment variable in MDT, and making that change seemed to be successful. (Still struggling with later errors so can't yet confirm the entire thing worked.)
I tried to run this script during the WinPE install phase, and it bombed with "DISM cannot service an image on a network path. Mount the image locally and run DISM again." In the DISM.log file it looks like it was trying to mount to my deployment share??
Hi. Thank you for this. I wanted to try this with our latest Windows 10 image, without using OSDBuilder.
To get the Apps, I used get-appxPackage – allusers | select-object Name, PackageFullName | out-string -width 1024 | out-file c:\apps.txt.
I then picked out the apps I wanted to remove and did a find replace on the PackageFullName to replace '_x64__' (two underscores) with '_neutral_~_'.
I then used these in the Apps array and it worked perfectly.
Hi James, thanks for sharing your findings!
Johan,
Where in MDT would this script be placed? Thank You
I have not tested the script with MDT, only ConfigMgr, but I would place it in the scripts folder.
Hi Johan, Yes that would be the easiest place for it. I guess what I meant was, where in a stand alone MDT task sequence would be a good spot for it. Thank You 🙂
Thanks for the usual great tips on how to work with all that.
However, where ist the link in the Option#2 that ist supposed to link to the script? There is no link there…
Greetings!
Should be there now
Hello, I downloaded the windows 11 23H2 iso and When I execute Import-OSMedia -ImageName $Edition -SkipGrid (with professionel edition) I have: Import-OSMedia BEGIN 2024-05-03-112555 Get-OSDBuilder: Validating OSDBuilder Content 2024-05-03-112555 AVERTISSEMENT : This version of OSDBuilder only supports: 2024-05-03-112555 AVERTISSEMENT : Windows 10 1607 – 21H2 2024-05-03-112555 AVERTISSEMENT : Windows 11 21H2 – 22H2 2024-05-03-112555 AVERTISSEMENT : Windows Server 2016 1607 – Windows Server 2022 21H1 ======================================================================================== 2024-05-03-112555 Media: Scan E:\Sources\install.wim ImageIndex 1: Windows 11 Famille ImageIndex 2: Windows 11 Famille N ImageIndex 3: Windows 11 Famille Unilingue ImageIndex 4: Windows 11 Éducation ImageIndex 5: Windows 11 Éducation N ImageIndex 6: Windows 11 Professionnel ImageIndex 7: Windows… Read more »
As far as I know, OSDBuilder is not tested against fully localized media. Use an English version of the media instead, and apply a French language pack.
Hello,
Thank you for your posts. I'm currently receiving the following error when running the "Import-OSMedia -ImageName $Edition -SkipGrid
Any help is much Appreciated.
Don't launch a separate PowerShell process. Run all commands from a script in ISE or in VSCode.
Thanks Johan,
For the great blog post as usual, for option 2 i believe you forget to add the script at the end of the post.
I'm sorry about that. I had to make some last-minute changes to the script, and it's available now.