Winget Error Handling
parent
34fbadb632
commit
3c30bfec00
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue