Removing Windows 10 in-box apps during a task sequence

A couple of years ago, Ben Hunter posted a script on the Deployment Guys blog that showed how to remove the in-box modern apps from a Windows 8.1 installation.  That exact same approach works with Windows 10 as well.  But there’s more that can be done, especially since the list of apps is different for Windows 8.1 and Windows 10 (and potentially changes with each Windows 10 feature upgrade), and since apps can be removed offline as well as online.

Attached to this blog (below) is the next generation of that script, designed to dynamically determine the list of apps if you don’t specify a list yourself.  It’s designed to run inside a task sequence (although it could be run manually if needed), either while in Windows PE to remove apps offline, or in the new OS to remove apps online.

Why would you want to remove apps offline?  A couple of reasons:

  • It’s faster.  By removing the apps offline, the provisioned apps won’t install when the OS boots up for the first time, so the first logon is faster and there’s no need to remove the installed apps either.
  • It avoids potential issues with the installation of provisioned apps.  All apps provisioned in the image install asynchronously on Windows 10 with the first logon.  So it’s possible that the task sequence starts removing apps while they are still being installed.  As a result, a script may fail to remove the app because it’s not there yet, and removing the provisioned app may not prevent the pending install from completing.  It’s a timing issue – your results may vary based on what happens in your specific task sequence.
  • It avoids potential issues with Windows Update.   Sometimes while building an image, the Windows Update agent can update the apps while you’re trying to remove them.  That can cause the removal to not work, and later if you try to sysprep and capture the image, that can fail.  (This is not a problem if you build your image on an isolated network with no internet access.)

Let’s talk about pre-requisites.  First, you need to use PowerShell to do this.  Online (within the running OS) that’s no big deal, since Windows 8.1 and Windows 10 include PowerShell by default.  But with Windows PE, it’s an optional component that needs to be added.  In addition to PowerShell, make sure you add the .NET Framework, the DISM Cmdlets, and the Storage Management Cmdlets components, as the script uses all of those.

Note that there can be some challenges with the original Windows 10 ADK when adding .NET and PowerShell to the boot image.  Those issues should be fixed in the November 2015 version of the ADK.  (We think that a separate problem with PowerShell failing in Windows PE with an exception at startup is also fixed in the new ADK, but you’ll need to verify that, we’re still trying.)  Also note that there are some issues with the November 2015 version of the ADK related to the use of the DISM component after MDT launches an HTA. See https://blogs.technet.com/b/mniehaus/archive/2015/12/31/updated-remove-apps-script-and-a-workaround.aspx for more details.

Next, you need to modify your task sequences.  Online, it should look something like this (with the steps running in the new OS):

image

Offline, it will look similar but the steps will be in a different location:

image

In either case, the “Set-ExecutionPolicy Bypass” step looks like this:

image

I also mentioned that the default behavior is to remove all apps.  What if you don’t want to remove all apps?  With previous scripts, we suggested modifying the script to change the list of apps that needs to be removed, but that can be rather tedious and requires knowing how to query the list (using Get-AppxPackage and Get-AppxProvisionedPackage).  So this script will write out an XML file, RemoveApps.xml, when it runs.  That contains the full list of apps.  So if you want to do a subset, just edit that file to remove the apps that you don’t want removed, then save the resulting file in the same location as the RemoveApps.ps1 script.  The script will find it and use that list instead of the full list.  (Note that if you use this with different OSes, you’ll want to use different lists.  So you may need multiple RemoveApps.xml files.  The script should pick up the file from the working folder specified in the task sequence.)

But what about the apps that can’t be removed?  There are several provisioned apps that Windows 10 won’t allow you to remove, so the script won’t even see those when it queries for the list.  So there will be apps remaining even if you say to remove “all” apps.  There’s no way around this.  (If there are some apps that you want to remove but you can’t, submit feedback via the Windows Feedback app.)

NOTE:  The attached script has been updated to version 1.1 as of 2015/12/30.

RemoveApps.zip