How to remove Windows 10 default AppX packages

Jordan Hammond fun headshot
Jordan Hammond|December 20, 2016
Generic blog header
Generic blog header

A common request we have is how to remove AppX packages, or in other words, remove Windows 10 default applications. First, you’ll see how to write and deploy a script to remove the applications, then we’ll look at an option for removing the application for all users on a workstation.

Building the script to remove Appx packages

To successfully remove AppX packages you’ll need two separate PowerShell scripts: one to remove the application(s) and one to prevent it from installing when a new user logs onto the desktop.

Remove Windows 10 default applications

To remove the existing Windows 10 software you need to decide which apps you would like to remove first. You can remove a single package with a one line script.

Get-AppxPackage |where {$_packagefullname -like "*zune*"} | Remove-AppxPackage

If, however, there is an entire list you would like it becomes a little more involved, you will need to create an array for each application you want to remove. For example:

$appname = @( "*BingWeather*" "*ZuneMusic*" "*ZuneVideo*" ) ForEach($app in $appname){ Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue }

You can add however many apps you like to the array and this script will cycle through and remove them. To get a full list of software you can remove you can run the following script on a Windows 10 machine:

Get-AppxPackage -AllUsers | select PackageFullName

Preventing Applications from Installing for New Users

The process for preventing the software from installing in the future is very similar. The only difference in the command is “provisioned” is added to the command name (Get-AppxProvisionedPackage). Here is how you get the list:

Get-AppxProvisionedPackage -online | select PackageName

And then to remove them from the preinstall list use the following script:

$appname = @( "*BingWeather*" "*ZuneMusic*" "*ZuneVideo*" ) ForEach($app in $appname){ Get-AppxProvisionedPackage -Online | where {$_.PackageName -like $app} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue }

Running the PowerShell Script Remotely

Now that we have the script we want we need to deploy it to the machines that you want to remove AppX packages from. This is where it starts to get tricky, if you create a package and run it with the default settings it will look like it did not do anything. The reason is the remove command does not have any ability to specify a specific user, so if you run it as the deploy user it will try and uninstall that software for the deploy user on that machine.

If you are in a work environment has one computer per user you can run this as the logged on user and it will work as you are hoping as long as the users are logged in at that time.

runasuser

For the AppxProvisionedPackage you can create the package with the defaults and it will still work as it is machine based and not user based.

Why These Scripts Do Not Remove Apps For Every User

Update 4/5/21: Since the time this blog went to publish, some of the details have changed.

As of build 1709 you can use -allusers to remove from all accounts. If your environment is using LTSC and still has 1709 or earlier, the information listed below is still for you. If you are on the more recent builds, you can absolutely remove them from all users. For a quick script that will let you remove all appx all users click here. Note: A critical part for the -allusers to work is including the -PackageFilterType. (I learned this the hard way while running this live)



If you have reached this point, you have been looking at this for awhile and you have found a lot of examples that say (incorrectly) if you run this command, then it will remove for every user:

Get-AppxPackage -AllUsers | Remove-AppxPackage

If you run it you’ll see nothing actually is removed. The reason has to do with the information that pipes over between the two commands. The first command (Get-AppxPackage) has an attribute (-AllUsers) that will look at each user on the computer, while the second command (Remove-AppxPackage) does not. That command while it does find packages for every user, it only passes over the name of the package, therefore it will only attempt to remove the package for the user running the script.

Alternative Solution

The challenge everyone runs into it is how do we remove AppX packages from all users that have logged into the machine previously without having to catch them while they are logged in. If all of your end users are local admins the very quick answer is add the PowerShell script as a logon script in Group Policy. If they are not local admins it takes a little work, but you can do it with PDQ Deploy.

Step 1: Build the PowerShell script. At the bottom I added two lines that will delete the script and batch file once the process is complete. (See Remove-Item)

$appname = @( "*BingWeather*" "*ZuneMusic*" "*ZuneVideo*" ) ForEach($app in $appname){ Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue } Remove-Item -Path "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\startup\test.bat" -Force Remove-Item -Path "$env:USERPROFILE\AppData\local\removeappxpackages.ps1" -Force

Step 2: Create batch file to start the new script and run it all silently. (See more about executionpolicy)

@echo off start Powershell.exe -executionpolicy remotesigned -windowstyle hidden -File %userprofile%\AppData\Local\removeappxpackages.ps1 /min

Step 3: Create a new package in PDQ Deploy with a PowerShell step that will copy the PowerShell script and batch file into each user profile that has had an interactive login. (See Copy-Item, Get-ChildItem, Test-Path)

$users = Get-ChildItem -Path "C:\Users" foreach($user in $users){ $path = "C:\Users\$($user.name)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" if(test-path $path){ Copy-Item -Path test.bat -Destination "$path\test.bat" -Force -ErrorAction Silentlycontinue Copy-Item -Path removeappxpackages.ps1 -Destination "C:\Users\$($user.name)\AppData\Local\" -Force -ErrorAction Silentlycontinue } }

Step 4: Add the files you created into the package.

addfiles Remove AppX Packages

Running this will make it so any user that has logged into a machine will have these applications removed the next time that they logon. They will not see anything and it removes them in under a minute. Running the remove-appxprovisionedpackage script from earlier will prevent it from installing these applications for all new users so you don’t have to run this script again.

Jordan Hammond fun headshot
Jordan Hammond

Jordan had spent his life wondering why tasks he didn’t like to do had no options to complete themselves. Eventually he had to make that happen on his own. It turned out that he enjoyed making tasks complete themselves, and PDQ thought that is something he should talk about on the internet.

Related articles