Winget Error Handling

pull/245/head
KnifMelti 2022-12-11 01:31:44 +01:00
parent 34fbadb632
commit 3c30bfec00
2 changed files with 10 additions and 3 deletions

View File

@ -84,7 +84,7 @@ if (Test-Network) {
}
else {
Write-Log "List doesn't exist!" "Red"
Exit 0
Exit 1
}
}
}
@ -125,6 +125,13 @@ if (Test-Network) {
Write-Log "Checking application updates on Winget Repository..." "yellow"
$outdated = Get-WingetOutdatedApps
#If something is wrong with the winget source, exit
if (($outdated -like "Problem:*")) {
Write-Log "An error occured, exiting..." "red"
Write-Log "$outdated" "red"
Exit 1
}
#Log list of app to update
foreach ($app in $outdated) {
#List available updates

View File

@ -11,9 +11,9 @@ function Get-WingetOutdatedApps {
#Get list of available upgrades on winget format
$upgradeResult = & $Winget upgrade --source winget | Out-String
#Start Convertion of winget format to an array. Check if "-----" exists
#Start Convertion of winget format to an array. Check if "-----" exists (Winget Error Handling)
if (!($upgradeResult -match "-----")) {
return
return "Problem:$upgradeResult"
}
#Split winget output to lines