From 31feaeb6f545b3da0ad1e15fa843fdf0e8001cf2 Mon Sep 17 00:00:00 2001 From: Jeffrey <9938813+Raphire@users.noreply.github.com> Date: Wed, 12 Aug 2026 21:10:47 +0200 Subject: [PATCH] Fix ForceRemoveEdge switch (#736) --- Scripts/AppRemoval/Invoke-ForceRemoveEdge.ps1 | 6 ++++++ Scripts/Features/Invoke-Changes.ps1 | 5 +++++ Tests/Invoke-Changes.Tests.ps1 | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/Scripts/AppRemoval/Invoke-ForceRemoveEdge.ps1 b/Scripts/AppRemoval/Invoke-ForceRemoveEdge.ps1 index e332436..48cca13 100644 --- a/Scripts/AppRemoval/Invoke-ForceRemoveEdge.ps1 +++ b/Scripts/AppRemoval/Invoke-ForceRemoveEdge.ps1 @@ -3,6 +3,12 @@ Forcefully uninstalls Microsoft Edge and removes its leftover shortcuts and autostart entries. #> function Invoke-ForceRemoveEdge { + if ($script:Params.ContainsKey("WhatIf")) { + Write-Host "[WhatIf] Forcefully uninstall Microsoft Edge" -ForegroundColor Cyan + Write-Host "" + return + } + Write-Host "> Forcefully uninstalling Microsoft Edge..." $regView = [Microsoft.Win32.RegistryView]::Registry32 diff --git a/Scripts/Features/Invoke-Changes.ps1 b/Scripts/Features/Invoke-Changes.ps1 index 7965774..02015b3 100644 --- a/Scripts/Features/Invoke-Changes.ps1 +++ b/Scripts/Features/Invoke-Changes.ps1 @@ -69,6 +69,11 @@ function Invoke-FeatureApply { Remove-SelectedApps $appsList return } + 'ForceRemoveEdge' { + Write-Host "> $applyText..." + Invoke-ForceRemoveEdge + return + } 'DisableWidgets' { Write-Host "> $applyText..." # Stop widgets related processes before removing the app packages to prevent potential issues diff --git a/Tests/Invoke-Changes.Tests.ps1 b/Tests/Invoke-Changes.Tests.ps1 index 130a87e..726b3bf 100644 --- a/Tests/Invoke-Changes.Tests.ps1 +++ b/Tests/Invoke-Changes.Tests.ps1 @@ -1,6 +1,7 @@ BeforeAll { function Import-RegistryFile { param($Message, $path) } function Remove-SelectedApps { param($Apps) } + function Invoke-ForceRemoveEdge {} function Disable-TelemetryScheduledTasks {} function Enable-TelemetryScheduledTasks {} function Generate-AppsList { @() } @@ -51,6 +52,7 @@ Describe 'Invoke-FeatureApply' { RemoveApps = [PSCustomObject]@{ ApplyText = 'Remove apps'; RegistryKey = '' } RemoveGamingApps = [PSCustomObject]@{ ApplyText = 'Remove gaming'; RegistryKey = '' } RemoveHPApps = [PSCustomObject]@{ ApplyText = 'Remove HP'; RegistryKey = '' } + ForceRemoveEdge = [PSCustomObject]@{ ApplyText = 'Force remove Edge'; RegistryKey = '' } DisableWidgets = [PSCustomObject]@{ ApplyText = 'Disable widgets'; RegistryKey = '' } EnableWindowsSandbox = [PSCustomObject]@{ ApplyText = 'Enable Sandbox'; RegistryKey = '' } EnableWindowsSubsystemForLinux = [PSCustomObject]@{ ApplyText = 'Enable WSL'; RegistryKey = '' } @@ -62,6 +64,7 @@ Describe 'Invoke-FeatureApply' { } Mock Import-RegistryFile {} Mock Remove-SelectedApps {} + Mock Invoke-ForceRemoveEdge {} Mock Disable-TelemetryScheduledTasks {} Mock Generate-AppsList { @() } Mock Get-FriendlyTargetUserName { 'current user' } @@ -116,6 +119,14 @@ Describe 'Invoke-FeatureApply' { Should -Invoke Remove-SelectedApps -Times 1 -Exactly -ParameterFilter { @($Apps) -join ',' -eq $ExpectedApps -join ',' } } + It 'forcefully removes Edge when requested' { + Invoke-FeatureApply -FeatureId 'ForceRemoveEdge' + + Should -Invoke Invoke-ForceRemoveEdge -Times 1 -Exactly + Should -Invoke Import-RegistryFile -Times 0 -Exactly + Should -Invoke Remove-SelectedApps -Times 0 -Exactly + } + It 'uses the expected static app list for ' -ForEach @( @{ FeatureId = 'RemoveGamingApps'; MinimumCount = 3; ExpectedApp = 'Microsoft.GamingApp' } @{ FeatureId = 'RemoveHPApps'; MinimumCount = 10; ExpectedApp = 'AD2F1837.myHP' }