Merge pull request #14 from Romanitho/test-retry

Retry if upgrade failed with install command (v2)
pull/19/head
Romain 2022-02-22 23:05:31 +01:00 committed by GitHub
commit bc5a286dc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 12 deletions

View File

@ -269,18 +269,27 @@ if (Test-Network){
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
#Winget upgrade #Winget upgrade
Write-Log "------ Winget - $($app.Name) Upgrade Starts ------" "Gray" Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR '$($app.Name)' ##########" "Gray"
& $upgradecmd upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append #Run Winget Upgrade command
Write-Log "----- Winget - $($app.Name) Upgrade Finished -----" "Gray" & $UpgradeCmd upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Check installed version #Check if application updated properly
$checkoutdated = Get-WingetOutdated $CheckOutdated = Get-WingetOutdated
$FailedToUpgrade = $false $FailedToUpgrade = $false
foreach ($checkapp in $checkoutdated){ foreach ($CheckApp in $CheckOutdated){
if ($($checkapp.Id) -eq $($app.Id)) { if ($($CheckApp.Id) -eq $($app.Id)) {
$FailedToUpgrade = $true #If app failed to upgrade, run Install command
& $upgradecmd install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Check if application installed properly
$CheckOutdated2 = Get-WingetOutdated
foreach ($CheckApp2 in $CheckOutdated2){
if ($($CheckApp2.Id) -eq $($app.Id)) {
$FailedToUpgrade = $true
}
}
}
} }
} Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR '$($app.Name)' ##########" "Gray"
#Notify installation #Notify installation
if ($FailedToUpgrade -eq $false){ if ($FailedToUpgrade -eq $false){