mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-23 08:02:07 +00:00
Add comprehensive test suite, fix minor issues, rename function and file names to match approved verbs (#708)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Serializes a configuration hashtable to a UTF-8 JSON file.
|
||||
|
||||
.PARAMETER Config
|
||||
The configuration data to serialize.
|
||||
|
||||
.PARAMETER FilePath
|
||||
The destination file path.
|
||||
|
||||
.PARAMETER MaxDepth
|
||||
The maximum object depth passed to ConvertTo-Json.
|
||||
|
||||
.OUTPUTS
|
||||
System.Boolean. $true when the file is written; otherwise $false.
|
||||
#>
|
||||
function Save-ToFile {
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user