From cd3ea88b5b4db7e937bb3180a881a4532c2f7455 Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Fri, 1 Nov 2024 18:01:40 +0100 Subject: [PATCH] Show additional info during app removal with `-Debug` parameter --- Win11Debloat.ps1 | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index 8a65391..d90bc0f 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -373,28 +373,46 @@ function RemoveApps { # Windows 11 build 22000 or later try { Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction Continue + + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Removed $app for all users" -ForegroundColor DarkGray + } } catch { - Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow - Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow + Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + } } } else { # Windows 10 try { Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue + + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Removed $app for current user" -ForegroundColor DarkGray + } } catch { - Write-Host "Unable to remove $app for current user" -ForegroundColor Yellow - Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Unable to remove $app for current user" -ForegroundColor Yellow + Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + } } try { Get-AppxPackage -Name $app -PackageTypeFilter Main, Bundle, Resource -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue + + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Removed $app for all users" -ForegroundColor DarkGray + } } catch { - Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow - Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + if($DebugPreference -ne "SilentlyContinue") { + Write-Host "Unable to remove $app for all users" -ForegroundColor Yellow + Write-Host $psitem.Exception.StackTrace -ForegroundColor Gray + } } } @@ -716,7 +734,7 @@ $WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\Current $global:Params = $PSBoundParameters $global:FirstSelection = $true -$SPParams = 'WhatIf', 'Confirm', 'Verbose', 'Silent', 'Sysprep' +$SPParams = 'WhatIf', 'Confirm', 'Verbose', 'Silent', 'Sysprep', 'Debug' $SPParamCount = 0 # Count how many SPParams exist within Params