SharePoint Online: How to Remove an App using PowerShell?

Requirement: Remove an App from SharePoint Online using PowerShell

How to Remove an App from SharePoint Online Site?
Apps that have been added to the SharePoint sites can later be removed if they are not needed. If you want to remove a specific app from the SharePoint Online site, do the following:
Make sure you are in classic SharePoint UI by clicking on the "Return to classic SharePoint" link at the bottom-left.
  • Login to your SharePoint Online site where you want to remove the app >> Click on Settings gear >> Choose "Site Contents" from the settings menu.
  • In the site contents page, Hover over the app you want to remove and click on the ellipsis (...). In the settings popup window click on the ellipsis (...)  again and then click Remove.
    remove app from sharepoint online
  • When prompted to remove the app, confirm by clicking OK.

PnP PowerShell to Remove an App from SharePoint Online Site:
We can also remove an app from SharePoint Online site collection using PnP PowerShell script.
#Parameters
$SiteURL = "https://crescentintranet.sharepoint.com/sites/Sales"
$AppName = "Adobe Sign"
 
#Connect to SharePoint Online App Catalog site
Connect-PnPOnline -Url $SiteURL -UseWebLogin

#Get the App Instance from Site
$App = Get-PnPAppInstance | Where {$_.Title -eq $AppName}
 
#UnInstall App from the Site
Uninstall-PnPAppInstance -Identity $App.Id
The selected app instance will be removed from the given site collection. however, If an app is no longer needed but has been deployed to a site, you will need to remove it from the App Catalog as well. You can also uninstall an app instance using PowerShell CSOM script SharePoint Online: Remove App using PowerShell

Please note, If an app is deployed through the tenant app catalog, both the above methods will not work! You will not get the "Remove" option for apps in the browser and the PowerShell method also won't work! These methods work only for app instances you added to the site directly. So to remove those app instances you have to uninstall them using the tenant app catalog as below.

Removing a deployed app from the Tenant App Catalog
If an app is deployed through app catalog to your SharePoint Online sites, You can remove that from multiple sites using App catalog site without requiring to remove from each individual site.
  • Login to SharePoint Online App Catalog site as an administrator
  • Click on Settings >> Site contents.
  • Select the ellipsis (...) next to the app you want to remove from other sites and select the ellipsis (...) again in the popup window. Select "Deployment".
    sharepoint online remove app powershell
  • The deployment page of the app lists all site collections where the particular app instances are deployed to. Select the sites from the site collections list and click on "Remove" to remove the app instance from selected sites. (If you want to delete the app instances from all sites, Remove every site listed in the site collections list).
  • Click OK at the bottom of the screen and then confirm the removal by clicking on the "Trust It" button in the confirmation popup window.
    sharepoint online remove app from catalog
The app will be removed from selected site collections and disappear from the site contents page.

Removing an App from the App Catalog
If you no longer want an app to be available for users to install from the App Catalog, you can remove it. To remove an app from the App Catalog, do the following:
  • Navigate to the App Catalog site and Click on "Site contents".
  • Hover over the app to remove, select the ellipsis (...), and choose the Remove option from the pop-up menu.
  • On the deletion confirmation screen, select the OK button to remove the app.
Delete App from "Apps for SharePoint" list 
For custom apps deployed to apps for SharePoint list in the App Catalog site,
  • Click on "Apps for SharePoint" in the left navigation (or from the site contents page)
    Select the app you want to remove, and click on "Delete." and Confirm.
Once the app is removed from the App Catalog, Users will no longer be able to add it to sites but existing app instances continue to work.

PnP PowerShell to Remove an App from App Catalog:
#Parameters
$AppCatalogSiteURL = "https://crescent.sharepoint.com/sites/Apps"
$AppName = "File Controller"
 
#Connect to SharePoint Online App Catalog site
Connect-PnPOnline -Url $AppCatalogSiteURL -UseWebLogin

#Get the from tenant App catalog
$App = Get-PnPApp -Scope Tenant | Where {$_.Title -eq $AppName}

#Remove an App from App Catalog Site
Remove-PnPApp -Identity $App.Id
  

Still finding the 3rd party app under "Apps you can Add"?
Well, you need to do one extra step if an app is still listed in your site collection under "Apps you can add".
  • Navigate to the SharePoint Online admin site
  • Click on More Features >> Click on "Open" under App Catalog
  • Click on "Manage Licenses" link under Apps page,
  • Select the app to remove >> Click on "Actions" >> Remove this license.
Now, the app should disappear from "apps you can add" section of site contents page.

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.