From 4e97645eea9a581593899f48b3030d5d9aca7c7c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 16 Aug 2024 15:04:37 +0200 Subject: [PATCH] Refactor `winget` check for rare issue --- scripts/Common/Scripts/SoftwareManagement.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/Common/Scripts/SoftwareManagement.ps1 b/scripts/Common/Scripts/SoftwareManagement.ps1 index 7cf6da06..8f781a63 100644 --- a/scripts/Common/Scripts/SoftwareManagement.ps1 +++ b/scripts/Common/Scripts/SoftwareManagement.ps1 @@ -78,10 +78,14 @@ function Test-Command { Checks whether `winget` is working properly. #> function Test-Winget { - (Test-Command winget) -and -not ( - [System.Linq.Enumerable]::Any( - [string[]](winget source update winget), - [System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; })); + (Test-Command winget) -and ( + & { + $output = winget source update winget; + + $? -and -not ([System.Linq.Enumerable]::Any( + [string[]]($output), + [System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; })); + }); } <#