Removing Applications from Your Windows 11 Image – Before and During Deployment

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:

  1. Remove the apps in the WIM image. This the static method.
  2. 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
Selecting which applications you want to remove.
Building the OS.

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

The install.wim after application removal.

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:

https://github.com/DeploymentResearch/DRFiles/blob/master/Scripts/Remove-UnwantedAppsWindows11offline.ps1

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.

About the author

Johan Arwidmark

5 2 votes
Article Rating
Subscribe
Notify of
guest
24 Comments
Newest
Oldest Most Voted
Neil Cole
Neil Cole
9 months ago

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.

Andrew Gavriluk
Andrew Gavriluk
1 year ago

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?

Last edited 1 year ago by Andrew Gavriluk
Andrews
Andrews
1 year ago

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"

Niclas NIlsson
Niclas NIlsson
1 year ago

Does #1 works for Windows 11 24H2
If not is it possible to get it to work?

Darren McDermott
Darren McDermott
1 year ago

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 .

Jennifer Smith
Jennifer Smith
2 years ago

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

Jennifer Smith
Jennifer Smith
2 years ago

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??

James Williams
James Williams
2 years ago

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.

Go Shen
Go Shen
2 years ago

Johan,
Where in MDT would this script be placed? Thank You

Last edited 2 years ago by Go Shen
Go Shen
Go Shen
2 years ago

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 🙂

Andreas
Andreas
2 years ago

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!

Bruno67
Bruno67
2 years ago

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 »

MichaelA
MichaelA
2 years ago

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.

errormessage
Ahmed
Ahmed
2 years ago

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.


>