Fix debug mode enable - recursively convert PS objects to hashtables

This commit is contained in:
Reditus committed 2026-05-19 07:08:54 +01:00
1 parent fb6e62021f
commit 690a3970d0
1 file changed
+17 -3
+17 -3
View File
@@ -2205,9 +2205,23 @@ print(json.dumps(s))
}
$settings = $settingsJson | ConvertFrom-Json
# Enable debug logging - convert to hashtable for reliable modification
$settingsHash = @{}
$settings.PSObject.Properties | ForEach-Object { $settingsHash[$_.Name] = $_.Value }
# Enable debug logging - convert entire object to nested hashtables
function ConvertTo-HashTable($obj) {
$hash = @{}
if ($obj -eq $null) { return $hash }
$obj.PSObject.Properties | ForEach-Object {
if ($_.Value -is [System.Management.Automation.PSCustomObject]) {
$hash[$_.Name] = ConvertTo-HashTable $_.Value
} elseif ($_.Value -is [System.Array]) {
$hash[$_.Name] = @($_.Value)
} else {
$hash[$_.Name] = $_.Value
}
}
return $hash
}
$settingsHash = ConvertTo-HashTable $settings
if (-not $settingsHash.logging) {
$settingsHash.logging = @{}