This SharePoint PowerShell tutorial, we will discuss, how to remove an app from SharePoint Online site using PowerShell. Here I have a SharePoint online developer site that has few SharePoint hosted add-ins deployed to the site.
If you are new to SharePoint hosted add-in previously known as SharePoint hosted apps, then you can see a video tutorial, Create and Deploy SharePoint Hosted Add-in using Visual Studio.
SharePoint Online tutorial contents:
We can easily remove SharePoint add-in or apps using a browser. Open the site and then go to the “Apps in Testing” library (I am doing this in a developer site). You can read about an article on the Developer site template overview and also you can read how to create a developer site in Office 365 SharePoint online.
Then click on (…) on the particular Add-in you want to remove. Then click on Remove like below.
This will remove the add-in from the site.
But sometimes while removing an add-in may be from the visual studio or manually, it does not remove properly. Sometimes it gave an error like: sorry we couldn’t remove the app.
In these cases, the best way is to remove the SharePoint hosted add-in by using PowerShell. But we need to first retrieve the AppInstanceId.
Open the site and then go to the “Apps in Testing” library. And then click on the (…) and then click on VIEW LOGS like below:
Then from browser, you can see the AppInstanceId like below:
Once the AppInstanceId is ready now we can run the below PowerShell script to remove the Add-in.
Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" $AppInstanceid = New-Object Guid("6F91CD30-7B5D-4A08-A06E-A72A82051813") $siteUrl = "https://onlysharepoint2013.sharepoint.com/sites/DevSite/" $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $securePassword=ConvertTo-SecureString "**********" -AsPlainText -Force $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(“email@example.com”, $securePassword) $web = $ctx.Web $appInst = $ctx.Web.GetAppInstanceById($AppInstanceid) $appInst.Uninstall(); $ctx.ExecuteQuery()
Once you run the above PowerShell script, you can see the removing status, here you can see it is showing Uninstalling.
After some time if you will refresh, the SharePoint add-in will already be removed from the SharePoint site.
Read some PowerShell Tutorials:
- How to check if file created last 24 hours using PowerShell?
- Insert/Add item to SharePoint Online list using PowerShell
- Delete list items created before N days using PowerShell in SharePoint Online
- Retrieve List Items Created in Last N days using PowerShell SharePoint Online
- SharePoint Online Create Workflow History List using PowerShell or using SharePoint Designer 2013
- SharePoint Online check if File exists or not in document library using PowerShell
- How to create and remove indexed column using PowerShell in SharePoint Online/2013/2016 list or document library?
- How to create and use PowerShell global variable
- Upload bulk documents to SharePoint 2016 document library using PowerShell
- PowerShell find files modified in last 24 hours and PowerShell get last modified time of files in folder
- Upload large files to SharePoint online document library using PowerShell csom
- Create an encrypted password file in PowerShell and use in SharePoint online
- SharePoint Online App Catalog – Detailed tutorial
In this SharePoint tutorial, we discussed how to remove app from SharePoint Online using PowerShell.
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 EnjoySharePoint.com