Files
Win11Debloat/Scripts/FileIO/SaveSettings.ps1
2026-02-15 23:08:54 +01:00

26 lines
729 B
PowerShell

# Saves the current settings, excluding control parameters, to 'LastUsedSettings.json' file
function SaveSettings {
$settings = @{
"Version" = "1.0"
"Settings" = @()
}
foreach ($param in $script:Params.Keys) {
if ($script:ControlParams -notcontains $param) {
$value = $script:Params[$param]
$settings.Settings += @{
"Name" = $param
"Value" = $value
}
}
}
try {
$settings | ConvertTo-Json -Depth 10 | Set-Content $script:SavedSettingsFilePath
}
catch {
Write-Output ""
Write-Host "Error: Failed to save settings to LastUsedSettings.json file" -ForegroundColor Red
}
}