Uninstall SharePoint store app through Powershell

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
 
#Set Parameters
$SiteURL = "https://contoso.sharepoint.com/sites/appcatalog1"
$AppInstanceID = New-Object Guid("d931644d-4eef-484b-adf8-5453a49e37d6")
  
#Setup Credentials to connect
#$Cred = Get-Credential
$Username = "sharepointadmin@contoso.com"
$Password = ConvertTo-SecureString -String "MyPassword1" -AsPlainText -Force
  
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
  
    #Get the App
    $App = $Ctx.Web.GetAppInstanceById($AppInstanceID)
    $Ctx.Load($App)
    $Ctx.ExecuteQuery()
 
    #Uninstall App Instance
    $App.Uninstall()
    $Ctx.ExecuteQuery()
     
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}
Filed under: Blog

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *
Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.