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
}
Related
No comment yet, add your voice below!