Skip to content

Commit 4da4b23

Browse files
authored
Handle Winget exit codes for uninstall operations
1 parent 26408a7 commit 4da4b23

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

DeployWorkstation.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,13 @@ function Remove-WingetApps {
614614
param([string[]]$AppPatterns)
615615
Write-Log "--- $(T 'ProgBloatware') ---" -Level 'SECTION'
616616

617+
# Winget exit codes that mean "nothing to uninstall" — treat as SKIPPED, not WARN
618+
$notFoundCodes = @(
619+
-1978335212, # 0x8A15002C no package found to uninstall
620+
-1978335189, # 0x8A15002B package not applicable / already gone
621+
-1978334966 # 0x8A15010A no installed package found
622+
)
623+
617624
$total = $AppPatterns.Count
618625
$current = 0
619626

@@ -643,6 +650,9 @@ function Remove-WingetApps {
643650
if ($LASTEXITCODE -eq 0) {
644651
Write-Log "$(T 'Removed'): $pattern" -Level 'SUCCESS'
645652
Add-Result -Section (T 'PhaseBloatware') -Item $pattern -Status 'OK' -Detail (T 'Removed')
653+
} elseif ($LASTEXITCODE -in $notFoundCodes) {
654+
Write-Log "$(T 'NotFound'): $pattern"
655+
Add-Result -Section (T 'PhaseBloatware') -Item $pattern -Status 'SKIPPED' -Detail (T 'NotInstalled')
646656
} else {
647657
Write-Log "$(T 'RemoveExitCode') $LASTEXITCODE for: $pattern" -Level 'WARN'
648658
Add-Result -Section (T 'PhaseBloatware') -Item $pattern -Status 'WARN' -Detail "$(T 'RemoveExitCode') $LASTEXITCODE"

0 commit comments

Comments
 (0)