From 136a5b19e9ccc1ef7d0399e950672fa5531cc2fe Mon Sep 17 00:00:00 2001 From: John McMillan <43364021+JMacIV@users.noreply.github.com> Date: Sun, 5 May 2024 06:20:19 -0400 Subject: [PATCH] Winget Version Testing Add (#52) * Added testing to make sure winget is version 1.4 or greater to make use of "disable-interactivity" flag Co-authored-by: Jeffrey <9938813+Raphire@users.noreply.github.com> --------- Co-authored-by: Jeffrey <9938813+Raphire@users.noreply.github.com> --- Win11Debloat.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index cc11971..4769231 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -331,7 +331,7 @@ function RemoveApps { if (($app -eq "Microsoft.OneDrive") -or ($app -eq "Microsoft.Edge")) { # Use winget to remove OneDrive and Edge if ($global:wingetInstalled -eq $false) { - Write-Host "WinGet is not installed, app was not removed" -ForegroundColor Red + Write-Host "WinGet is either not installed or is outdated, so $app could not be removed" -ForegroundColor Red } else { # Uninstall app via winget @@ -498,12 +498,20 @@ function AwaitKeyToExit { } -# Check if winget is installed -if (Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") { + # Check if winget is installed & if it is, check if the version is at least v1.4 +if ((Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") -and ((winget -v) -replace 'v','' -gt 1.4)) { $global:wingetInstalled = $true } else { $global:wingetInstalled = $false + + # Show warning that requires user confirmation, Suppress confirmation if Silent parameter was passed + if (-not $Silent) { + Write-Warning "Winget is not installed or outdated. This may prevent Win11Debloat from removing certain apps." + Write-Output "" + Write-Output "Press any key to continue anyway..." + Read-Host | Out-Null + } } # Hide progress bars for app removal, as they block Win11Debloat's output