2026-02-15 23:08:54 +01:00
|
|
|
# Prints all pending changes that will be made by the script
|
|
|
|
|
function PrintPendingChanges {
|
2026-03-22 22:07:51 +01:00
|
|
|
$skippedParams = @()
|
|
|
|
|
$undoChanges = $script:Params.ContainsKey('Undo')
|
2026-03-22 23:44:59 +01:00
|
|
|
|
|
|
|
|
if ($undoChanges) {
|
|
|
|
|
Write-Output "Win11Debloat will make the following changes to revert the selected settings to Windows defaults:"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Write-Output "Win11Debloat will make the following changes:"
|
|
|
|
|
}
|
2026-02-15 23:08:54 +01:00
|
|
|
|
|
|
|
|
if ($script:Params['CreateRestorePoint']) {
|
|
|
|
|
Write-Output "- $($script:Features['CreateRestorePoint'].Label)"
|
|
|
|
|
}
|
|
|
|
|
foreach ($parameterName in $script:Params.Keys) {
|
|
|
|
|
if ($script:ControlParams -contains $parameterName) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
2026-03-22 22:07:51 +01:00
|
|
|
if ($parameterName -eq 'Apps' -or $parameterName -eq 'CreateRestorePoint') {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($undoChanges) {
|
|
|
|
|
$undoFeature = GetUndoFeatureForParam -paramKey $parameterName
|
|
|
|
|
if (-not $undoFeature) {
|
|
|
|
|
$skippedParams += $parameterName
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-15 23:08:54 +01:00
|
|
|
|
|
|
|
|
# Print parameter description
|
|
|
|
|
switch ($parameterName) {
|
|
|
|
|
'Apps' {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
'CreateRestorePoint' {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
'RemoveApps' {
|
|
|
|
|
$appsList = GenerateAppsList
|
|
|
|
|
|
|
|
|
|
if ($appsList.Count -eq 0) {
|
|
|
|
|
Write-Host "No valid apps were selected for removal" -ForegroundColor Yellow
|
|
|
|
|
Write-Output ""
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Output "- Remove $($appsList.Count) apps:"
|
|
|
|
|
Write-Host $appsList -ForegroundColor DarkGray
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
'RemoveAppsCustom' {
|
|
|
|
|
$appsList = LoadAppsFromFile $script:CustomAppsListFilePath
|
|
|
|
|
|
|
|
|
|
if ($appsList.Count -eq 0) {
|
|
|
|
|
Write-Host "No valid apps were selected for removal" -ForegroundColor Yellow
|
|
|
|
|
Write-Output ""
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Output "- Remove $($appsList.Count) apps:"
|
|
|
|
|
Write-Host $appsList -ForegroundColor DarkGray
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
if ($script:Features -and $script:Features.ContainsKey($parameterName)) {
|
2026-03-22 22:07:51 +01:00
|
|
|
$action = if ($undoChanges -and $script:Features[$parameterName].UndoAction) {
|
|
|
|
|
$script:Features[$parameterName].UndoAction
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$script:Features[$parameterName].Action
|
|
|
|
|
}
|
2026-02-15 23:08:54 +01:00
|
|
|
$message = $script:Features[$parameterName].Label
|
2026-03-22 22:07:51 +01:00
|
|
|
if ($action) {
|
|
|
|
|
Write-Output "- $action $message"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Write-Output "- $message"
|
|
|
|
|
}
|
2026-02-15 23:08:54 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# Fallback: show the parameter name if no feature description is available
|
|
|
|
|
Write-Output "- $parameterName"
|
|
|
|
|
}
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 22:07:51 +01:00
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 23:08:54 +01:00
|
|
|
Write-Output ""
|
|
|
|
|
Write-Output ""
|
|
|
|
|
Write-Output "Press enter to execute the script or press CTRL+C to quit..."
|
|
|
|
|
Read-Host | Out-Null
|
|
|
|
|
}
|