How to Remove an App from a SharePoint 2013 Site using Powershell Script

I have a site named http://c4968397007/sites/Vijai/ in which I have added my app called "MyFirstSharePointHostedApp". In this blog you will see how to remove an app from a SharePoint site using powershell script.

Powershell Script:

### App Name

$AppName="MyFirstSharePointHostedApp"

 

### Get the App Instance from SharePoint site

$appInstance = Get-SPAppInstance -Web "http://c4968397007/sites/Vijai" | where-object {$_.Title -eq $AppName}

 

### Check if the app exists in the site

if ($appInstance -ne $null)

{

Write-Host -ForegroundColor Green "Uninstalling the app from the SharePoint site....";

### Remove the app from the site

Uninstall-SPAppInstance –Identity $appInstance

}