diff --git a/powershell/libres-softwares-install.ps1 b/powershell/libres-softwares-install.ps1 index 108cfec..bee290f 100644 --- a/powershell/libres-softwares-install.ps1 +++ b/powershell/libres-softwares-install.ps1 @@ -6,6 +6,9 @@ param() $ErrorActionPreference = "Continue" +# winget exit code: package already installed and already at latest version +$WingetExitNoUpdateAvailable = -1978335189 + function Initialize-Winget { if (Get-Command winget -ErrorAction SilentlyContinue) { return @@ -101,11 +104,16 @@ function Install-FirefoxEsr { $Process = Start-Process -FilePath "winget" -ArgumentList $Arguments -NoNewWindow -Wait -PassThru + if ($Process.ExitCode -eq $WingetExitNoUpdateAvailable) { + Write-Host "Firefox ESR is already up to date." -ForegroundColor Green + return + } + if ($Process.ExitCode -ne 0) { throw "Firefox ESR installation failed. winget exit code: $($Process.ExitCode)" } - Write-Host "Firefox ESR installed or already present." -ForegroundColor Green + Write-Host "Firefox ESR installed or updated." -ForegroundColor Green } } @@ -435,6 +443,10 @@ foreach ($logiciel in $logicielsAInstaller) { Write-Host "OK $($logiciel.Nom) installe avec succes" -ForegroundColor Green $reussites++ $resultats += @{Logiciel = $logiciel.Nom; Statut = "Succes"} + } elseif ($process.ExitCode -eq $WingetExitNoUpdateAvailable) { + Write-Host "OK $($logiciel.Nom) deja a jour" -ForegroundColor Green + $reussites++ + $resultats += @{Logiciel = $logiciel.Nom; Statut = "Deja a jour"} } else { Write-Host "ERREUR Echec de l'installation de $($logiciel.Nom) (Code: $($process.ExitCode))" -ForegroundColor Red $echecs++ @@ -454,7 +466,7 @@ Write-Host "===========================================================" -Foregr Write-Host "" foreach ($resultat in $resultats) { - if ($resultat.Statut -eq "Succes") { + if ($resultat.Statut -eq "Succes" -or $resultat.Statut -eq "Deja a jour") { Write-Host "[OK] $($resultat.Logiciel): $($resultat.Statut)" -ForegroundColor Green } else { Write-Host "[X] $($resultat.Logiciel): $($resultat.Statut)" -ForegroundColor Red