From b1cf364c7d89d83f24b68d7738c40584b85623ee Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Mon, 23 Mar 2026 21:03:22 +0100 Subject: [PATCH] Don't allow undo in combination with deployment-targeted parameters --- Win11Debloat.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index 649af41..e0f48bc 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -334,8 +334,16 @@ foreach ($Param in $script:ControlParams) { } } -# Guard: Undo mode requires at least one actionable, non-control parameter. +# Guard: Undo mode requires at least one actionable and cannot be combined with deployment-targeted parameters if ($script:Params.ContainsKey('Undo')) { + $deploymentTargetParams = @('Sysprep', 'User', 'AppRemovalTarget') + $selectedDeploymentParams = @($deploymentTargetParams | Where-Object { $script:Params.ContainsKey($_) }) + + if ($selectedDeploymentParams.Count -gt 0) { + Write-Error "The -Undo parameter cannot be combined with deployment target parameters: -$($selectedDeploymentParams -join ', -')." + AwaitKeyToExit + } + $loadsSettingsFromPreset = $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings $undoTargets = @($script:Params.Keys | Where-Object { ($script:ControlParams -notcontains $_) -and $_ -ne 'Apps' -and $_ -ne 'CreateRestorePoint'