Remove Windows Store apps in Windows 8

Introduction

This script can be used to remove multiple Windows Store apps from a user account in Windows 8. It provides a list of installed Windows Store apps.  You can specify the application IDs, and remove them all at once.

Scenarios

In Windows 8, you can remove a single Windows Store app by right-clicking the tile in the Start menu and choosing the uninstall command.  However, no command is provided for removing multiple Windows Store apps all at once.  If you want to do so, you can use this script sample.

Sometimes Windows Store apps may crash in Windows 8.  Even though you can successfully uninstall and reinstall the app, the app may still crash after the reinstallation.  In this situation, you can use this example script to remove these Windows Store apps cleanly.

Script

Step 1: Move the cursor to the top right corner of the screen, click Search, type PowerShell, right-click the Windows PowerShell app tile, and then, on the app bar, click Run as administrator.


Examples 

Example 1: How to display help about the script

You can type the command Get-Help C:\Script\RemoveWindowsStoreApp.ps1  -Full to display the entire help file for this function, such as the syntax, parameters, or examples. This is shown in the following figure.

Example 2: How to remove Windows Store apps

To remove Windows Store apps, run the script directly, then choose the ID of each app that you want to remove.

In this example, I suppose that you decide to remove "Games" and "Maps". The Windows Store apps as shown below.

Run the script, and then choose the IDs for the "Games" and "Maps" apps (The IDs should be 4 and 17). Finally, confirm this action.
 

The apps have been removed!

Here are some code snippets for your reference.

PowerShell
Edit|Remove
foreach ($ID in $IDs) 
{ 
    #check id is in the range 
    if ($ID -ge 1 -and $ID -le $apps.count) 
    { 
        $ID-- 
        #Remove each app 
        $AppName=$apps[$ID].name 
        if($PSCmdlet.ShouldProcess("$AppName")) 
        { 
            Remove-AppxPackage -Package $apps[$ID] -ErrorAction SilentlyContinue 
            if (-not(Get-AppxPackage -Name $AppName)) 
            { 
                Write-host "$AppName has been removed successfully"}else{ 
                Write-Warning "Remove '$AppName' failed! This app is part of Windows and cannot be uninstalled on a per-user basis."}}}else{ 
        $errorMsg = $Messages.WrongID 
        $errorMsg = $errorMsg -replace "Placeholder01",$ID 
        $customError = PSCustomErrorRecord ` 
        -ExceptionString $errorMsg ` 
        -ErrorCategory NotSpecified -ErrorID 1 -TargetObject $pscmdlet 
        $pscmdlet.WriteError($customError) 
    }}

 

Additional Resources

Technical Resources:

Windows PowerShell Advanced Function

http://technet.microsoft.com/en-us/library/dd315326.aspx

Get-AppxPackage
http://technet.microsoft.com/en-us/library/hh856044.aspx

 Remove-AppxPackage
http://technet.microsoft.com/en-us/library/hh856038.aspx