mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-18 19:56:25 +00:00
Starting from this commit, Win11Debloat will automatically create a registry backup every time the script is run. This registry backup can be used to revert any registry changes made by the script.
23 lines
497 B
PowerShell
23 lines
497 B
PowerShell
# Saves configuration JSON to a file.
|
|
# Returns $true on success, $false on failure.
|
|
function SaveToFile {
|
|
param (
|
|
[Parameter(Mandatory=$true)]
|
|
[hashtable]$Config,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$FilePath,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[int]$MaxDepth = 10
|
|
)
|
|
|
|
try {
|
|
$Config | ConvertTo-Json -Depth $MaxDepth | Set-Content -Path $FilePath -Encoding UTF8
|
|
return $true
|
|
}
|
|
catch {
|
|
return $false
|
|
}
|
|
}
|