1

I have the following script to update my SharePoint app with the latest version but it always fails with the error:

Install-SPApp : An instance of this App already exists at the specified

when the app is already installed on the site. For SPSolutions I can wait on while ($solution.JobExists) is there an equivalent for SharePoint Apps (.app)?

#check if app already exists
$instances = Get-SPAppInstance -Web $siteCol
$instance = $instances | where {$_.Title -eq $file.BaseName}
if($instance -ne $null){
    Write-Host "Uninstalling app " $file.BaseName

    Uninstall-SPAppInstance -Identity $instance -Confirm:$false
    #need to wait here
}

Write-Host "Installing app " $file.BaseName
#install the app
$spapp = Import-SPAppPackage  –Path $file.FullName  –Site $siteCol  -Source ObjectModel -Confirm:$false
$newInstance = Install-SPApp –Web $siteCol -Identity $spapp 

1 Answer 1

1

I was able to find the answer in this MSDN blog

There is an Update-SPAppInstance method to be used when an app is already installed and then you can wait on the status of the AppInstance

while (($appInstance.Status -eq ([Microsoft.SharePoint.Administration.SPAppInstanceStatus]::Upgrading))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.