15 September 2020

Preventing Windows 10 Apps from Reappearing after an In-Place or Feature Upgrade

In the imaging process I devised, most of the Windows 10 Built-In apps, such as mail and maps, are removed. My company uses the SAC edition of Windows 10 enterprise. This requires us to perform an in-place upgrade every 6 months. In order to prevent the built-in apps from reappearing, you can add specific registry keys that permanently deprovision the apps. 

The first thing you will need to do is to get a list of the apps you want to deprovision. To do so, execute the following PowerShell one-liner to get a list of the apps with the display name on the right with the associated package name on the left. The package name is what will be needed. 

 Get-AppxProvisionedPackage -Online | Select DisplayName, PackageName | Sort-Object -Property DisplayName | Export-Csv -Path Apps.txt -Force -Encoding UTF8 -NoTypeInformation  

It is best to edit the CSV file in excel. Once you open the generated text file up, delete those items you do NOT want the OS to remove, and then delete the DisplayName column. The CSV file is now ready to be used with the PowerShell script. You will need to rerun the above PowerShell script each time an OS upgrade is available and has been installed to get any new additions. 

The script will read the contents of the text file and then adds those as a registry key located under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned. You can find out more information on the registry keys and how they work here

The following script will only need to be executed once. You can download it from my GitHub site


 <#  
      .SYNOPSIS  
           Deprovision Specified Windows 10 Apps  
        
      .DESCRIPTION  
           This script will add the appropriate registry keys to deprovision the built-in Windows 10 applications specified in the associated text file, or hardcoded in the script.  
        
      .PARAMETER AppListFile  
           File containing list of Windows 10 files to deprovision  
        
      .NOTES  
           ===========================================================================  
           Created with:     SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.142  
           Created on:       9/15/2020 9:56 AM  
           Created by:       Mick Pletcher  
           Filename:         Windows10AppDeprovisioning.ps1  
           ===========================================================================  
 #>  
   
 [CmdletBinding()]  
   
 param  
 (  
      [string]$AppListFile  
 )  
   
 #Get list of Windows 10 Applications to uninstall from text file  
 $Applications = Get-Content -Path $AppListFile  
 #Deprovisioned Registry Key  
 $RegKey = 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned'  
 #Create deprovisioned registry key if it does not exist  
 If (!(Test-Path $RegKey)) {  
      New-Item -Path $RegKey -Force | Out-Null  
 }  
 #Add list of Apps from the imported text file to the deprovisioned registry key  
 foreach ($App in $Applications) {  
      #Install registry key if it does not exist  
      If (!(Test-Path ($RegKey + '\' + $App))) {  
           New-Item -Path ($RegKey + '\' + $App) -Force | Out-Null  
      }  
 }  
   

0 comments:

Post a Comment