Skip to content

Commit 0e1ff30

Browse files
authored
Enhance error handling and logging in DeployWorkstation
Added a new known failure code for missing packages in winget source and adjusted logging for cleaner output.
1 parent 2d3357d commit 0e1ff30

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

DeployWorkstation.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ function Install-StandardApps {
867867
# Known permanent failure codes — not retried, shown with a friendly message
868868
$knownFailMessages = @{
869869
-1978335215 = 'Installer hash mismatch (try again later or check proxy/AV)' # 0x8A150011
870+
-1978335212 = 'Package not found in winget source (ID may have changed)' # 0x8A15002C
870871
-1978334960 = 'Installer blocked by security policy' # 0x8A150110
871872
-1978335132 = 'Installer requires reboot before proceeding' # 0x8A150064
872873
}
@@ -944,11 +945,15 @@ function Install-StandardApps {
944945
"Exit code $exitCode"
945946
}
946947
Write-Log "$(T 'InstallFail'): $($app.Name) - $failReason" -Level 'WARN'
947-
# Log last clean lines of winget output — strip progress-bar/non-printable chars
948-
$diagLines = ($wingetOut | Where-Object { "$_".Trim() }) | Select-Object -Last 5
948+
# Log last clean lines of winget output — strip progress-bar/spinner noise
949+
$diagLines = ($wingetOut | Where-Object { "$_".Trim() }) | Select-Object -Last 8
949950
foreach ($line in $diagLines) {
951+
# Strip non-printable chars, then skip spinner frames and short noise
950952
$clean = ("$line" -replace '[^\x20-\x7E]', '').Trim()
951-
if ($clean.Length -gt 3) { Write-Log " $clean" -Level 'WARN' }
953+
if ($clean.Length -lt 8) { continue } # too short (spinner: \|/-)
954+
if ($clean -match '^[\\|/\-]+$') { continue } # pure spinner frame
955+
if ($clean -match '^\s*\d+\s*MB') { continue } # progress bytes only
956+
Write-Log " $clean" -Level 'WARN'
952957
}
953958
Add-Result -Section (T 'PhaseApps') -Item $app.Name -Status 'WARN' -Detail $failReason
954959
$script:Summary.AppsFailed++

0 commit comments

Comments
 (0)