locked
Script to remove the provisioned apps RRS feed

  • Question

  • I'm new to powershell scripting. I'm wondering why "$($app)" doesn't get evaluated. 

    # variable which produces the list of all the provisioned apps

    $apps = Get-AppxProvisionedPackage -online| select-object -property Displayname

    #loop to remove all the provisioned apps by passing it to the parameter

    ForEach($app in $apps){
       $app | Remove-AppxPackage -Package "$($app)"
    }


    • Edited by RokSul Wednesday, June 19, 2019 12:06 PM
    Wednesday, June 19, 2019 11:42 AM

All replies

  • Get-AppxProvisionedPackage -online |  Remove-AppxPackage


    \_(ツ)_/

    Wednesday, June 19, 2019 12:23 PM
  • I tried it got error thrown that's why i created a script like that. I can see the list of the application when i run 

    Get-AppxProvisionedPackage -online but when i pipe the command that's when i get the error.

    + Get-AppxProvisionedPackage -online |  Remove-AppxPackage
    +                                       ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (Microsoft.Dism....pxPackageObject:String) [Remove-AppxPackage], IOException
        + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand

    Wednesday, June 19, 2019 1:01 PM
  • Because packages are protected.  You  must be running elevated and understand how these packages work.  System pckages cannot be removed.

    You also cannot remove any package the is deployed to a user.

    You can do this for some packages:

    Get-AppxProvisionedPackage -online |  Remove-AppxPackage  -AllUsers


    \_(ツ)_/

    Wednesday, June 19, 2019 1:06 PM
  • Thursday, June 20, 2019 12:56 AM
  • Unfortunately you can't remove the package until you have removed the app from all users.


    \_(ツ)_/

    Thursday, June 20, 2019 1:00 AM
  • You can either do:

    get-appxprovisionedpackage -online | remove-appxprovisionedpackage -online

    while will affect future new users.  Or

    get-appxpackage | remove-appxpackage

    which will affect the current user.

    I haven't had much luck with 

    remove-appxpackage -user

    or

    remove-appxpackage -allusers

    • Edited by JS2010 Thursday, June 20, 2019 2:24 AM
    Thursday, June 20, 2019 2:22 AM
  • You have to enumerate the packages and use a foreach to specify the package path to the remove. 


    \_(ツ)_/

    Thursday, June 20, 2019 2:31 AM
  • I meant to post it here.  You need windows 10 1809 for this.

    get-appxpackage *pattern* | remove-appxpackage -AllUsers

    Thursday, June 20, 2019 2:57 PM