Remove an app from SharePoint site using PowerShell

This SharePoint tutorial will discuss how to install and uninstall an app from the SharePoint site using PowerShell.

We will see how to remove apps from the SharePoint 2013/2016 site using PowerShell. And also, we will discuss how to remove the app from sharepoint online using Powershell.

Remove an app from SharePoint 2016/2013 PowerShell

Recently we have added on SharePoint free app from the App store into our SharePoint 2016 site and then we want to remove that by using PowerShell.

Uninstall-SPAppInstance is the PowerShell cmdlet to remove the app from the SharePoint site. The PowerShell cmdlet will work in SharePoint server 2013/2016/2019 to remove the app from SharePoint.

Below is the PowerShell command to remove SharePoint app using PowerShell which you can run in Windows PowerShell ISE like below:

Add-PSSnapin Microsoft.SharePoint.PowerShell
$appInstance = Get-SPAppInstance -Web “http://mypc:29024/sites/SPTraining/” | where-object {$_.Title -eq $AppName}
if ($appInstance -ne $null)
Uninstall-SPAppInstance –Identity $appInstance

Once you run this it will ask for the confirmation message and click on Yes to All to execute it.

Remove app from SharePoint Online using PowerShell

Now we will see how to remove the app from sharepoint online using Powershell.

Add-Type -Path 'C:\Users\Bijaya.Sahoo\Desktop\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Users\Bijaya.Sahoo\Desktop\Microsoft.SharePoint.Client.Runtime.dll'
catch {
$appInstanceid = New-Object Guid("xxxx-xx-xx-xx-xxxx")
$siteUrl = ""
$username = "[email protected]"
$password=ConvertTo-SecureString "********" -AsPlainText -Force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials

$appInst = $ctx.Web.GetAppInstanceById($appInstanceId)

Once you execute the above PowerShell script, the app will be removed from the SharePoint Online site.

You may like following SharePoint tutorials:

This PowerShell SharePoint tutorial, we learned how to remove an app from SharePoint 2013/2016 or SharePoint Online site using PowerShell.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.