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
$AppName=”Employees”
$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.

Try{
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 = "https://tsinfo.sharepoint.com/sites/Bhawana/"
$username = "bijay@tsinfo.onmicrosoft.com"
$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)
$appInst.Uninstall()
$ctx.ExecuteQuery()
$ctx.Dispose()

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.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>