Adding and Removing Windows 10 Apps with PowerShell

PowerShell, Uncategorized

Raise your hand if you’ve ever had problems removing Windows 10 Apps. Raise your other hand if you’re fancy enough to know these by their name, Universal Windows Platform apps.

If you’ve got both hands up, clap them together. You’re fancy!

Generally speaking, removing Windows 10 Apps with PowerShell can be tricky. Once you get the hang of it, however, you may find it surprisingly straightforward.

In contrast to the fire hose blast of info in our webcast about Windows 10 Apps and Advertising (link here), I’m going to keep this blog relatively simple and code-focused.

Before we begin, there are some important things to note:

  • Remove-AppxPackage only removes apps for the current user
  • Remove-AppxProvisionedPackage doesn’t uninstall the app, it removes the provisioned package from Windows
  • Removing provisioned packages prevents new users from receving a Windows App
  • All glory to the hypnotoad

Also, there is no time for raised hands, so put your hands down and let’s get typing!

Removing Windows 10 Apps

You have before you the PowerShell gold that is removing Windows 10 apps. These commands will help with removing Windows 10 apps in a very simple and straightforward way.

Get installed Windows 10 Apps
Get-AppxPackage

 

Get Installed Windows 10 Apps by Name
Get-AppxPackage *weather*

 

Get Installed Windows 10 Apps for all users
Get-AppxPackage -AllUsers

 

Get Installed Windows 10 Apps by Name for all users
Get-AppxPackage *weather* -AllUsers

 

Removing Windows 10 Apps by name
Get-AppxPackage *weather* | Remove-AppxPackage

 

Removing Windows 10 Apps by list
$AppList = @(

    "*Bing*",
    "*zune*"

)

foreach ($App in $AppList) {

    Get-AppxPackage -Name $App | Remove-AppxPackage

}
Removing Windows 10 Apps with an exception list
$ExceptionList = @(

    "*WindowsStore*",
    "*calc*"

)

Get-AppxPackage | Where { $App = $_; -not ( $ExceptionList | Where-Object { $App -like $_ } ) } | Remove-AppxPackage

Adding Windows 10 Apps

Now that we’ve mastered removing Windows 10 Apps, this is how we add Windows 10 Apps back. That is, if you ever decide to walk that lonely road.

Add Windows 10 App from Manifest
$AppName = "Weather"
$AppPath = @()
$AppPath += Get-ChildItem 'C:\Program Files\WindowsApps\' -Filter "*$AppName*x86*" | Select -ExpandProperty FullName
$AppPath += Get-ChildItem 'C:\Program Files\WindowsApps\' -Filter "*$AppName*x64*" | Select -ExpandProperty FullName

Add-AppxPackage -DisableDevelopmentMode -Register "$AppPath\AppxManifest.xml"

 

Add Windows 10 App from Provisioned Apps List
$ProvisionedList = (Get-AppxProvisionedPackage -Online).DisplayName
$AppPaths = @()
foreach ($App in $ProvisionedList) {

    $AppPaths += Get-ChildItem 'C:\Program Files\WindowsApps' -Filter "$App*x86*" | Select -ExpandProperty FullName
    $AppPaths += Get-ChildItem 'C:\Program Files\WindowsApps' -Filter "$App*x64*" | Select -ExpandProperty FullName

}

$AppPaths | ForEach-Object { 

    Add-AppxPackage -DisableDevelopmentMode -Register "$_\AppxManifest.xml" 

}

 

Removing Windows 10 App Provisions

While removing Windows 10 Apps is important, we need to prevent them from being added in the first place. Using the following code, you’ll be able to do just that.

 

Get Provisioned Windows 10 Apps
Get-AppxProvisionedPackage -Online

 

Get Provisioned Windows 10 Apps by Name
Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like "*weather*"}

 

Removing Provisioned Windows 10 Apps by List
$AppList = @(

    "*bing*",
    "*zune*"

)

foreach ($App in $AppList) {

    Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like $App} | Remove-AppxProvisionedPackage -Online

}

 

Things to keep in mind

Even though I said this at the start of the blog, it’s worth saying again, removing Windows 10 Apps happens per user

As of this moment, there is not a way to directly remove Windows 10 Apps for another user. As a result, there are a lot of blogs and forum posts on the internet with info that is wrong.

Yep. I said it. They’re wrong. Who could have ever guessed?! People are actually wrong on the internet!

Simply put, it’s because the Remove-AppxPackage cmdlet only works for the current user.

 

To sum it up, the above code will not remove SomePackage for all users. In fact, it will only remove the package from the current user.

Since we’re not doing a deep dive today, I’ll spare you the fancy details. But, if you’re curious, you’ll find a RemovePackageAsync method on the PackageManager class description page. That’s what Remove-AppxPackage uses.

In any case, this means you’ll have to use another method to get the apps removed from users who are not currently logged on. Here are a few ideas that we’ve come up with:

  • Putting a script in the startup folder (check out Jordan’s blog post)
  • Using Scheduled tasks
  • Using PDQ Deploy
  • Using Logon Scripts

Also, if you’re a fan of the DESTROY EVERYTHING approach, you may run into some issues. For example, Cortana and Edge browser are considered core apps and cannot be removed. So, you’ll have to plan ahead for what you want to remove.

In any case, have fun destroying all the things.

Happy PowerShelling!

Leave a Reply

Your email address will not be published. Required fields are marked *