Flexible Security For Your Peace of Mind

Remove unwanted APPX applications

(Last updated on March 4, 2020)

Have you ever wanted to deploy a Windows 10 client, but without all the built-in Windows Store applications that it comes with? This is possible with running a simple script in MDT.

The following script removes unwanted applications after the operating system installation. Use the $WhiteListedApps variable to set the apps you want to keep, and the $WhiteListOnDemand variable to set the Features on Demand you want to keep. You can copy and save it as a Powershell script file (.ps1).

# Functions
function Write - LogEntry
{
  param([parameter(Mandatory = $true, HelpMessage = "Value added to the RemovedApps.log file.")][ValidateNotNullOrEmpty()][string] $Value, [parameter(Mandatory = $false, HelpMessage = "Name of the log file that the entry will written to.")][ValidateNotNullOrEmpty()][string] $FileName = "RemovedApps.log") # Determine log file location $LogFilePath = Join - Path - Path $env: windir - ChildPath "Temp\$($FileName)"
  # Add value to log file
  try
  {
    Add - Content - Value $Value - LiteralPath $LogFilePath - ErrorAction Stop
  }
  catch [System.Exception]
  {
    Write - Warning - Message "Unable to append log entry to RemovedApps.log file"
  }
}
# Get a list of all apps Write - LogEntry - Value "Starting built-in AppxPackage and AppxProvisioningPackage removal process"
$AppArrayList = Get - AppxPackage - PackageTypeFilter Bundle - AllUsers | Select - Object - Property Name, PackageFullName | Sort - Object - Property Name # White list of appx packages to keep installed $WhiteListedApps = @(# "Microsoft.BingWeather", # "Microsoft.BioEnrollment", "Microsoft.DesktopAppInstaller", # "Microsoft.GetHelp", # "Microsoft.Getstarted", # "Microsoft.Messaging", # "Microsoft.Microsoft3DViewer", # "Microsoft.MicrosoftOfficeHub", # "Microsoft.MicrosoftSolitaireCollection", # "Microsoft.MicrosoftStickyNotes", # "Microsoft.MixedReality.Portal", "Microsoft.MSPaint", # "Microsoft.Office.OneNote", # "Microsoft.OneConnect", # "Microsoft.People", #aktivera sen # "Microsoft.Print3D", "Microsoft.ScreenSketch", # "Microsoft.SkypeApp", "Microsoft.StorePurchaseApp", # "Microsoft.Wallet", "Microsoft.Windows.Photos", # "Microsoft.WindowsAlarms", # "Microsoft.WindowsCamera", # "Microsoft.Windows.CapturePicker", # "Microsoft.Windows.Cortana", # "Microsoft.Windowscommunicationsapps", # Mail, calender osv.# "Microsoft.WindowsFeedbackHub", # "Microsoft.WindowsMaps", "Microsoft.WindowsSoundRecorder", "Microsoft.WindowsStore", # "Microsoft.Xbox.TCUI", # "Microsoft.XboxApp", # "Microsoft.XboxGameOverlay", # "Microsoft.XboxGamingOverlay", # "Microsoft.XboxIdentityProvider", # "Microsoft.XboxSpeechToTextOverlay", # "Microsoft.YourPhone", # "Microsoft.ZuneMusic", # "Microsoft.ZuneVideo"
  "Microsoft.WindowsCalculator") # Loop through the list of appx packages foreach($App in $AppArrayList)
{
  # If application name not in appx package white list, remove AppxPackage and AppxProvisioningPackage
  if (($App.Name - in $WhiteListedApps))
  {
    Write - LogEntry - Value "Skipping excluded application package: $($App.Name)"
  }
  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
    if ($AppPackageFullName - ne $null)
    {
      try
      {
        Write - LogEntry - Value "Removing application package: $($App.Name)"
        Remove - AppxPackage - Package $AppPackageFullName - ErrorAction Stop | Out - Null
      }
      catch [System.Exception]
      {
        Write - LogEntry - Value "Removing AppxPackage failed: $($_.Exception.Message)"
      }
    }
    else
    {
      Write - LogEntry - Value "Unable to locate AppxPackage for app: $($App.Name)"
    }
    # Attempt to remove AppxProvisioningPackage
    if ($AppProvisioningPackageName - ne $null)
    {
      try
      {
        Write - LogEntry - Value "Removing application provisioning package: $($AppProvisioningPackageName)"
        Remove - AppxProvisionedPackage - PackageName $AppProvisioningPackageName - Online - ErrorAction Stop | Out - Null
      }
      catch [System.Exception]
      {
        Write - LogEntry - Value "Removing AppxProvisioningPackage failed: $($_.Exception.Message)"
      }
    }
    else
    {
      Write - LogEntry - Value "Unable to locate AppxProvisioningPackage for app: $($App.Name)"
    }
  }
}
# White list of Features On Demand V2 packages Write - LogEntry - Value "Starting Features on Demand V2 removal process"
$WhiteListOnDemand = "NetFX3|Tools.Graphics.DirectX|Tools.DeveloperMode.Core|Language|Browser.InternetExplorer|WindowsMediaPlayer|App.Support.QuickAssist"
# Get Features On Demand that should be removed $OnDemandFeatures = Get - WindowsCapability - Online | Where - Object
{
  $_.Name - notmatch $WhiteListOnDemand - and $_.State - like "Installed"
} | Select - Object - ExpandProperty Name foreach($Feature in $OnDemandFeatures)
{
  try
  {
    Write - LogEntry - Value "Removing Feature on Demand V2 package: $($Feature)"
    Get - WindowsCapability - Online - ErrorAction Stop | Where - Object
    {
      $_.Name - like $Feature
    } | Remove - WindowsCapability - Online - ErrorAction Stop | Out - Null
  }
  catch [System.Exception]
  {
    Write - LogEntry - Value "Removing Feature on Demand V2 package failed: $($_.Exception.Message)"
  }
}
# Complete Write - LogEntry - Value "Completed built-in AppxPackage and AppxProvisioningPackage removal process"

Add the script to a share and follow the steps below to add it to your task sequence in MDT. Alternatively, if you are a Specops Deploy user, you can add it to the scripts folder in your deployment repository.

  1. Open the Deployment Workbench.
  2. Connect to your Deployment Share.
  3. Select Task Sequences.
  4. Select the Windows 10 image that you would like to remove the APPX applications from.
  5. Right click on the image and select Properties.
  6. Select the Task Sequence tab.
  7. Select State Restore.
  8. Click Add – General – Run Powershell Script.
  9. Name the script Cleanup appx applications.
  10. Enter the path where your script is located.
  11. Click OK.

If you are using Specops Deploy/OS remember to publish your Deployment Repository.

After you deploy your Windows 10 client with the script in your MDT task sequences, you will have a nice clean start menu without all of the Microsoft default applications. To further customize your start menu, read Customize the Windows 10 start menu.

Tags: , , ,

Written by

Johan Soderstrom

Product Specialist, Specops Software

More Articles
Back to Blog