SharePoint Online: Uninstall App Instance using PowerShell

Requirement: Uninstall an App Instance using PowerShell.

PowerShell to Remove an App instance from SharePoint Online Site
Could not remove an app instance in SharePoint Online site from browser interface! Here is the PowerShell to remove an app from SharePoint Online site.
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

#Set Parameters
$SiteURL = ""
$AppInstanceID = New-Object Guid("d0c3efd3-4ac4-4172-a3ed-aa108845aced")
#Setup Credentials to connect
$Cred = Get-Credential
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
    #Get the App
    $App = $Ctx.Web.GetAppInstanceById($AppInstanceID)

    #Uninstall App Instance
Catch {
    write-host -f Red "Error:" $_.Exception.Message
How to get App Instance Id?
To obtain the App instance ID, follow these steps:
  • Go to your SharePoint Online site where the App instance is created
  • Click on Settings gear >> Site Contents
  • In the Site contents page, Hover over the app and click on ellipses(...) of the App and click Details menu
  • The app instance ID can be obtained from the details URL. E.g. Url: /_layouts/15/AppMonitoringDetails.aspx?AppInstanceId={GUID}

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.