Remove all new UWP apps except few

Peter Volz 1,295 Reputation points
2023-06-03T17:56:18.3633333+00:00

Hello,

I've found this Power Shell script some years ago to run after each Win10 fresh install:

 Get-AppxPackage -AllUsers |
	Where-Object {$_.name -notmatch 'DesktopAppInstaller|WindowsCalculator|WindowsFeedbackHub|WindowsStore|XboxApp.....'} |
	Remove-AppxPackage

To remove all new terrible apps, except few ones.....

Now, under latest version of Win10 22H2, I ran Get-AppxPackage -AllUsers and it seems those names are changed:

'DesktopAppInstaller|WindowsCalculator|WindowsFeedbackHub|WindowsStore|XboxApp.....'

And a 'Microsoft.' is added to the beginning of all those packages, am I right that the script should be now?

 Get-AppxPackage -AllUsers |
	Where-Object {$_.name -notmatch 'Microsoft.DesktopAppInstaller|Microsoft.WindowsCalculator|Microsoft.WindowsFeedbackHub|Microsoft.WindowsStore|Microsoft.XboxApp.....'} |
	Remove-AppxPackage
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,182 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,321 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,831 Reputation points
    2023-06-03T18:48:31.8+00:00

    I'd do it in a slightly different way, because as your regex grows longer the chance of introducing errors increases. Using a simple character-based match might have an effect on one package, but an error in the regex may remove an awful lot! Also, the original script uses a regular expression to determine the packages to keep, but now that list includes a period which means "match any one character". More, your regex looks for a match anywhere in the name rather than match the entire name.

    $keepers =  'Microsoft.DesktopAppInstaller','Microsoft.WindowsCalculator','Microsoft.WindowsFeedbackHub',
                'Microsoft.WindowsStore','<continue the list>'
    Get-AppxPackage -AllUsers |
    	Where-Object {$keepers -notcontains $_.name} |
    	    Remove-AppxPackage
    

    You should also review that list of packages you want to keep (you didn't include the entire regex). You'll find stuff like "Microsoft.WindowsAppRuntime.1.2", "Microsoft.NET.Native.Runtime.2.2", etc. that you probably shouldn't be removing.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful