Add option to revert previous changes to windows defaults

This commit is contained in:
Raphire
2026-03-22 22:07:51 +01:00
parent edd815fdbb
commit a54c3c6918
14 changed files with 697 additions and 56 deletions

View File

@@ -1,5 +1,7 @@
# Prints all pending changes that will be made by the script
function PrintPendingChanges {
$skippedParams = @()
$undoChanges = $script:Params.ContainsKey('Undo')
Write-Output "Win11Debloat will make the following changes:"
if ($script:Params['CreateRestorePoint']) {
@@ -9,6 +11,17 @@ function PrintPendingChanges {
if ($script:ControlParams -contains $parameterName) {
continue
}
if ($parameterName -eq 'Apps' -or $parameterName -eq 'CreateRestorePoint') {
continue
}
if ($undoChanges) {
$undoFeature = GetUndoFeatureForParam -paramKey $parameterName
if (-not $undoFeature) {
$skippedParams += $parameterName
continue
}
}
# Print parameter description
switch ($parameterName) {
@@ -46,9 +59,19 @@ function PrintPendingChanges {
}
default {
if ($script:Features -and $script:Features.ContainsKey($parameterName)) {
$action = $script:Features[$parameterName].Action
$action = if ($undoChanges -and $script:Features[$parameterName].UndoAction) {
$script:Features[$parameterName].UndoAction
}
else {
$script:Features[$parameterName].Action
}
$message = $script:Features[$parameterName].Label
Write-Output "- $action $message"
if ($action) {
Write-Output "- $action $message"
}
else {
Write-Output "- $message"
}
}
else {
# Fallback: show the parameter name if no feature description is available
@@ -59,6 +82,18 @@ function PrintPendingChanges {
}
}
if ($undoChanges -and $skippedParams.Count -gt 0) {
Write-Output ""
Write-Output "The following changes cannot be automatically undone and will be skipped:"
$uniqueSkipped = $skippedParams | Sort-Object -Unique
foreach ($skippedParam in $uniqueSkipped) {
$action = $script:Features[$skippedParam].Action
$message = $script:Features[$skippedParam].Label
Write-Output "- $action $message"
}
}
Write-Output ""
Write-Output ""
Write-Output "Press enter to execute the script or press CTRL+C to quit..."