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.

Demo

Get Microsoft Silverlight

Scenarios

1. 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.

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

Script

This script contains only the Remove-OSCAppxPackage function. To use this script, follow these steps:
  1. Download the script.
  2. Open the script by using Notepad or another text editor.
  3. Scroll down to the end of the script file, and then add the example command that you want to run. Then, save the script.
  4. Open PowerShell.
  5. Run the script.
 

Examples 

Example 1: How to display help about the Remove-OSCAppxPackage function
To display help about the Remove-OSCAppxPackage function, run the following command:
    Get-Help Remove-OSCAppxPackage –Full
 
  
Example 2: How to remove Windows Store Apps
To remove Windows Store apps, run the following command, then choose the ID of each App that you want to remove:
      Remove-OSCAppxPackage
Note: Before you run this command, the Windows Store Apps appear as below. You decide to remove "Games" and "Maps".
 
 
 
Run the command, then choose the IDs for the "Games" and "Maps" Apps (The IDs should be 4 and 17). Then, confirm this action.

 
The Apps have been removed!
 
 
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
  
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-Error "Remove $AppName failed!" 
            } 
        } 
    } 
    else 
    { 
        $errorMsg = $Messages.WrongID 
        $errorMsg = $errorMsg -replace "Placeholder01",$ID 
        $customError = New-OSCPSCustomErrorRecord ` 
        -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