I'm trying to make my own de-bloat script that will remove both provisioned and user apps from Windows 10. I've made a list of the provisioned apps using this command Get-AppXProvisionedPackage -Online | Select DisplayName and filtered it out to show the displayname of each app. In the code below I'm trying to place each listed app into the command below so that I have got to write it out multiple times. Could someone explain where I'm going wrong please?

P.S I'm extremely new to PowerShell.

# This script de-bloats unwanted apps from Windows 10.
# To keep certain apps insert a '#' at the beginning of the line 
# and it will be skipped from being removed. 

Write-Output "Uninstalling provisioned apps"
$ProvisionedApps = @(

foreach ($app in $ProvisionedApps) {
    Write-Output "REMOVING $app"

    Get-AppXProvisionedPackage -Online | Where-Object DisplayName -EQ $ProvisionedApps | Remove-AppxProvisionedPackage -Online

Many thanks


  • Welcome. What error are you getting? Please make your title reflect your question/problem. – I say Reinstate Monica Sep 12 '19 at 16:50
  • Your Where-Object compares with the whole collection instead of the currently iterated $app – LotPings Sep 12 '19 at 19:37

You may consult the detailed debloating PowerShell script at Windows10-Unbloating-v1.ps1.

The actual code used (I changed variable names to yours) is:

foreach ($app in $ProvisionedApps) {
    Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
    Get-AppXProvisionedPackage -Online | Where-Object DisplayName -EQ $app | Remove-AppxProvisionedPackage -Online

You will notice in the Get-AppXProvisionedPackage command the use of the $app variable instead of $ProvisionedApps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.