Remove Built-in apps when creating a Windows 10 reference image

186_1_1

When creating your reference image for Windows 10, you might want to remove the Universal Apps for various reasons. The community have come up with several scripts to accomplish this task, and don’t want to take any credit for coming up with the idea to do it with PowerShell. However, I wanted to share my version of a PowerShell script that removed the built-in apps in Windows 10.

In this script, I’ve taken another approach compared to those created by other community members. Since new versions of Windows 10 will emerge 2-3 times a year, I don’t want to update a script to support the new version that might incorporate new Universal Apps. Instead, I’m white-listing Universal Apps that I want to keep (like the Calculator), and remove everything else. In my experience, this should lead to the least amount of maintenance and that’s what I’m all about.

Script

Below you’ll find a variety of versions for the script that I’ve created. As with the release of Windows 10 1607, a few more apps were added compared to Windows 10 version 1511. Select the script for which version of Windows 10 that you’re deploying. You could of course just take any of the scripts below, edit the if condition on row 7 and make the changes that you seem fit in terms of which apps that should not be removed.

Windows 10 version 1511
# Get a list of all apps
$AppArrayList = Get-AppxPackage -PackageTypeFilter Bundle | Select-Object -Property Name, PackageFullName | Sort-Object -Property Name

# Loop through the list of apps
foreach ($App in $AppArrayList) {
    # Exclude essential Windows apps
    if (($App.Name -in "Microsoft.WindowsCalculator","Microsoft.WindowsStore","Microsoft.Appconnector","Microsoft.WindowsCommunicationsApps","Microsoft.WindowsSoundRecorder")) {
        Write-Output -InputObject "Skipping essential Windows app: $($App.Name)"
    }
    # Remove AppxPackage and AppxProvisioningPackage
    else {
        # Gather package names
        $AppPackageFullName = Get-AppxPackage -Name $App.Name | Select-Object -ExpandProperty PackageFullName
        $AppProvisioningPackageName = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like $App.Name } | Select-Object -ExpandProperty PackageName
        # Attempt to remove AppxPackage
        try {
            Write-Output -InputObject "Removing AppxPackage: $AppPackageFullName"
            Remove-AppxPackage -Package $AppPackageFullName -ErrorAction Stop
        }
        catch [System.Exception] {
            Write-Warning -Message $_.Exception.Message
        }
        # Attempt to remove AppxProvisioningPackage
        try {
            Write-Output -InputObject "Removing AppxProvisioningPackage: $AppProvisioningPackageName"
            Remove-AppxProvisionedPackage -PackageName $AppProvisioningPackageName -Online -ErrorAction Stop
        }
        catch [System.Exception] {
            Write-Warning -Message $_.Exception.Message
        }
    }
}
Windows 10 version 1607
# Get a list of all apps
$AppArrayList = Get-AppxPackage -PackageTypeFilter Bundle | Select-Object -Property Name, PackageFullName | Sort-Object -Property Name

# Loop through the list of apps
foreach ($App in $AppArrayList) {
    # Exclude essential Windows apps
    if (($App.Name -in "Microsoft.WindowsCalculator", "Microsoft.WindowsStore", "Microsoft.Appconnector", "Microsoft.WindowsCommunicationsApps", "Microsoft.WindowsSoundRecorder", "Microsoft.DesktopAppInstaller", "Microsoft.Messaging", "Microsoft.StorePurchaseApp")) {
        Write-Output -InputObject "Skipping essential Windows app: $($App.Name)"
    }

    # Remove AppxPackage and AppxProvisioningPackage
    else {
        # Gather package names
        $AppPackageFullName = Get-AppxPackage -Name $App.Name | Select-Object -ExpandProperty PackageFullName
        $AppProvisioningPackageName = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like $App.Name } | Select-Object -ExpandProperty PackageName

        # Attempt to remove AppxPackage
        try {
            Write-Output -InputObject "Removing AppxPackage: $($AppPackageFullName)"
            Remove-AppxPackage -Package $AppPackageFullName -ErrorAction Stop
        }
        catch [System.Exception] {
            Write-Warning -Message $_.Exception.Message
        }

        # Attempt to remove AppxProvisioningPackage
        try {
            Write-Output -InputObject "Removing AppxProvisioningPackage: $($AppProvisioningPackageName)"
            Remove-AppxProvisionedPackage -PackageName $AppProvisioningPackageName -Online -ErrorAction Stop
        }
        catch [System.Exception] {
            Write-Warning -Message $_.Exception.Message
        }
    }
}

Using the script in MDT

1. Using this script is really no brainer, simply download it, call it Invoke-RemoveBuiltinApps.ps1 and place it in the %SCRIPTROOT% directory, meaning the <DeploymentShareRoot>\Scripts directory in MDT.
186_2
2. In your task sequence for Windows 10, add a Run PowerShell Script step and set the PowerShell Script field to:

%SCRIPTROOT%\Invoke-RemoveBuiltinApps.ps1

186_3_1
Start your reference image creation process and watch the magic happen!

15 Comments

  1. Eden Oliveira

    Hi Nickolaj, Thank you for one more nice script.

    I have a question, I have already my Gold image built, I normally remove those apps using DISM offline, which takes some time to mount image, perform the actions, unmount, etc.
    So I was wondering, Can I use this script on my ConfigMgr 2012 Task Sequence?

    If so, how should I proceed?

    I believe I would need to create a package (no program) using this script, right?

    At which step should I add this script to on my TS?

    Thank you in advance.

    Eden

    Reply
  2. Pingback: Windows 10 Task Sequence

  3. Dan Padgett

    just execute it as a TS step for run command line..

    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file .\script.ps1

    make sure you specify a source for script

    Reply
  4. Pingback: Charlie's Tech Ramblings » Blog Archive » Fully automate your Build and Capture using MDT

  5. Pingback: How to get rid of Candy Crush Soda Saga and other Windows 10 Start Menu junk for good! - Page 2

  6. Jo Smith

    I’ve been removing “windowscommunicationsapps”. Is that really an essential app? We don’t use Calendar, Mail, or Contacts/People, so I figured it wasn’t needed. I hope it doesn’t break anything.

    Reply
  7. João Torres

    Congratulations for your amazing script, however I have a doubt. How can I remove the apps for all users? Even if it’s a new user. Because when I deployed the captured image whit your script on the TS, I logged in for the first time on the VM with the captured image but the apps still there. I tried your script on the current user and it works like a charm, but when I change user, the apps still there for the new user.

    Best Regards.

    Reply
  8. Anders

    Hi
    i can’t get this to work. Deployment log returns: “TSHOST: Script completed with return code 0 TaskSequencePSHost 2016-06-21 16:07:59 0 (0x0000)
    ” it does not remove any app at all. In task sequense it runs before pre win update.

    Reply
  9. Petr Riha

    Hi & let me say THX for incredible forum at the beginning. My issue is that I tried already several options how to remove Appx from Windows 10 x64, x86 Enterprise Edt. nevertheless all new users has installed apps like CandyCrash, XBox,.. :(. Can you give me an advice where this step should be exactly situated within SCCM Task Sequence to make it working please? The same issue I am dealing with setup StartMenu modification & language settings & I hope that with some advice I will be able to solve all. Thank you in advance.

    Reply
    1. Benoit Lecours

      Hi Petr,

      Candy Crush and Xbox are application that are installed by the store automatically. You will need to disable Microsoft Consumer Experiences to get rid of those. See the how-to in my post (there’s a part about Start Menu as well) : https://www.systemcenterdudes.com/sccm-windows-10-customization/

      Reply
  10. Steve Whitcher

    Thanks for updating this post. Do you happen to know what the each of the new built-in apps in v1607 do?

    I’m guessing DesktopAppInstaller is for the upcoming feature allowing win32 apps to be installed from the store, which is definitely one to keep.

    I thought that Messaging is the SMS app for mobile and for text messaging on a PC when paired with a windows mobile or android device. Do I have that wrong, or is there a reason that you consider this an essential app?

    What about StorePurchaseApp, which I see that you kept, and OneConnect, which you didn’t? Any idea what either of these do?

    Reply
  11. Steve

    Any way to get further information for each built-in application? Looking for specifically which each application is so we can make a meaningful decision to leave in or take out of the image.

    Reply
    1. NickolajNickolaj (Post author)

      Unfortunately, I’m not aware of any such documentation. Would also like to have that information.

      Reply
  12. Sam

    Does this script work offline?

    I got this to work online (during the state restore phase) but will not work during the post-install phase.

    Reply
  13. Pingback: SCCM Windows 10 Default Apps

Leave a Comment

Your email address will not be published. Required fields are marked *