Better support "unknown" app versions

pull/8/head
Romain 2022-02-21 12:46:53 +01:00
parent ba83f2b531
commit 9b1f6f059b
1 changed files with 9 additions and 7 deletions

View File

@ -213,12 +213,10 @@ function Get-WingetOutdated {
$software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd()
$software.Version = $line.Substring($versionStart, $availableStart - $versionStart).TrimEnd() $software.Version = $line.Substring($versionStart, $availableStart - $versionStart).TrimEnd()
$software.AvailableVersion = $line.Substring($availableStart, $sourceStart - $availableStart).TrimEnd() $software.AvailableVersion = $line.Substring($availableStart, $sourceStart - $availableStart).TrimEnd()
#check if Avalaible Version is > than Current Version (block "unknow" versions loop) #add formated soft to list
if ([version]$software.AvailableVersion -gt [version]$software.Version){
$upgradeList += $software $upgradeList += $software
} }
} }
}
return $upgradeList return $upgradeList
} }
@ -259,7 +257,7 @@ if (Test-Network){
#For each app, notify and update #For each app, notify and update
foreach ($app in $outdated){ foreach ($app in $outdated){
if (-not ($toSkip -contains $app.Id)){ if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne "Unknown"){
#Send available update notification #Send available update notification
Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan" Write-Log "Updating $($app.Name) from $($app.Version) to $($app.AvailableVersion)..." "Cyan"
@ -309,6 +307,10 @@ if (Test-Network){
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
} }
} }
#if current app version is unknown
elseif($($app.Version) -eq "Unknown"){
Write-Log "$($app.Name) : Skipped upgrade because current version is 'Unknown'" "Gray"
#if app is in "excluded list"
else{ else{
Write-Log "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray" Write-Log "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray"
} }
@ -324,4 +326,4 @@ if (Test-Network){
#End #End
Write-Log "End of process!" "Cyan" Write-Log "End of process!" "Cyan"
Sleep 3 Start-Sleep 3