Intune and PowerShell – Remove Bloatware

Microsoft (and other companies) seem to be increasing the number of semi-useless applications that they install every time a feature version of Windows comes out. A great example of these are the Xbox apps that Microsoft started pushing in Windows 10 version 1909. Back in the days of imaging through MDT servers and task sequences, it was easy to get rid of unwanted software. Now with on-premises environments starting to get phased out and more companies switching over to Entra ID only devices setup with Autopilot, it can be a pain to get these unwanted apps off users’ devices.  Fortunately, we can still use a tried-and-true method like PowerShell.


Scripting the Uninstalls

Since most business now have a mix of Windows 10 and Windows 11 devices, I recommend using the AppxPackage cmdlets to find and remove applications.

First, you need to find the names of the bloatware or other apps you want removed. You can run a simple command to get a list of all the AppxPackages that are installed:

Get-AppxPackage -AllUsers | Select-Object Name | Sort-Object -Property Name

Scroll through the list and copy the names of the apps you want removed. I chose the following:

  •     Microsoft.ZuneVideo
  •     Microsoft.ZuneMusic
  •     Microsoft.XboxGamingOverlay
  •     Microsoft.XboxGameOverlay
  •     Microsoft.Xbox.TCUI

1. Let’s start with creating a variable to hold the names of all the AppxPackages installed on the computer. Make sure that foreach { $_.Name } is after the pipe and not select-object Name. We just want the text value of name and the property itself since our array in step 2 only contains text values.

 $list = Get-AppxPackage -AllUsers | foreach { $_.Name }

2. We will then create an array that contains the apps we want to remove:

$bloatware = @(

          "Microsoft.ZuneVideo"

          "Microsoft.ZuneMusic"

          "Microsoft.XboxGamingOverlay"

          "Microsoft.XboxGameOverlay"

          "Microsoft.Xbox.TCUI"

         )

3. Finally, we’ll add a foreach loop to step through the bloatware app list, see if that app is found in the installed list, and remove it if it is.

foreach ($i in $bloatware){

            if ($i -in $list){

            Get-AppxPackage -Name $i -Allusers | Remove-AppxPackage 

            }

        }

Important note: You have to use the -allusers flag if you are going to deploy this script from Intune. We have to set the script to run as System since users don’t have permission to remove apps. There are no AppxPackages installed under the System account, so your script will fail without this flag.

4. Here is the Powershell script I use to remove Windows 10/11 bloatware:

#Get list of all installed apps
$list = Get-AppxPackage -AllUsers | foreach { $_.Name }
#Create array with list of apps we want to remove

$bloatware = @(
"Microsoft.ZuneVideo"
"Microsoft.ZuneMusic"
"Microsoft.XboxGamingOverlay"
"Microsoft.XboxGameOverlay"
"Microsoft.Xbox.TCUI")

#loop through the bloatware apps and check if they are installed
foreach ($i in $bloatware)
  {
    if ($i -in $list)
    {
     Get-AppxPackage -Name $i -Allusers | Remove-AppxPackage 
    }
  }

         

5. Open Intune admin center > Devices > Scripts and Remediations > Platform Scripts and upload your script. Deploy it to existing devices or a dynamic device group that contains autopilot devices to make sure unwanted apps are removed during the autopilot process.

A script like this should only need to be run once since users shouldn’t be able to re-install these apps (or install any apps) and IT definitely shouldn’t be re-installing these apps. If you have to run it more than once, you can create a remediation instead. For more information on remediations you can check out my blog post on them. Otherwise, here is what I used as a detection script and remediation script:

Detection

#Get list of all installed apps
$list = Get-AppxPackage -AllUsers | foreach { $_.Name }
$foundapps = 0
#Create array with list of apps we want to remove
$bloatware = @(
    "Microsoft.ZuneVideo"
    "Microsoft.ZuneMusic"
    "Microsoft.XboxGamingOverlay"
    "Microsoft.XboxGameOverlay"
    "Microsoft.Xbox.TCUI"
)

#loop through the bloatware apps and check if they are installed
foreach ($i in $bloatware){
if ($i -in $list){
     $foundapps++
      }
}
if ($foundapps -gt 0){
     exit 1
}

else{
     exit 0
}

Remediation

$list = Get-AppxPackage -AllUsers | foreach { $_.Name }
$bloatware = @(
    "Microsoft.ZuneVideo"
    "Microsoft.ZuneMusic"
    "Microsoft.XboxGamingOverlay"
    "Microsoft.XboxGameOverlay"
    "Microsoft.Xbox.TCUI"
)
foreach ($i in $bloatware){
       if ($i -in $list){
       Get-AppxPackage -Name $i -AllUsers | Remove-AppxPackage
       }
}

Leave a Comment

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

Scroll to Top