I am installing apps using powershell script and I want my script as rerunnable.
try
{
$web.GetAppInstanceById()
$appIoStream = New-Object IO.FileStream($AppFilePath,[System.IO.FileMode]::Open)
$appInstance = $web.LoadAndInstallApp($appIoStream) | Out-Null
$context.ExecuteQuery()
Write-Host $appInstance.Id
}
catch
{
$appIoStream.Dispose();
Write-Host "Unable to Install App -" $AppName ": $_.Exception.Message" -foregroundcolor black -backgroundcolor Red
return
}
Using this I can able to achieve the apps to be installed in the site collection.But when I am again running the powershell script I got an error that "an instance of this app is already exists at specified location". How can I handle this?