Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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