Files
Win11Debloat/Scripts/FileIO/SaveToFile.ps1
T

23 lines
497 B
PowerShell
Raw Normal View History

# Saves configuration JSON to a file.
# Returns $true on success, $false on failure.
function SaveToFile {
param (
[Parameter(Mandatory=$true)]
[hashtable]$Config,
[Parameter(Mandatory=$true)]
2026-05-08 21:19:52 +02:00
[string]$FilePath,
[Parameter(Mandatory=$false)]
[int]$MaxDepth = 10
)
try {
2026-05-08 21:19:52 +02:00
$Config | ConvertTo-Json -Depth $MaxDepth | Set-Content -Path $FilePath -Encoding UTF8
return $true
}
catch {
return $false
}
}