mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Add ability to export/import settings configuration (#522)
This commit is contained in:
@@ -16,10 +16,7 @@ function SaveSettings {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$settings | ConvertTo-Json -Depth 10 | Set-Content $script:SavedSettingsFilePath
|
||||
}
|
||||
catch {
|
||||
if (-not (SaveToFile -Config $settings -FilePath $script:SavedSettingsFilePath)) {
|
||||
Write-Output ""
|
||||
Write-Host "Error: Failed to save settings to LastUsedSettings.json file" -ForegroundColor Red
|
||||
}
|
||||
|
||||
19
Scripts/FileIO/SaveToFile.ps1
Normal file
19
Scripts/FileIO/SaveToFile.ps1
Normal file
@@ -0,0 +1,19 @@
|
||||
# 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
|
||||
)
|
||||
|
||||
try {
|
||||
$Config | ConvertTo-Json -Depth 10 | Set-Content -Path $FilePath -Encoding UTF8
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user