JSON to Registry
Aus Wiki-WebPerfect
This PowerShell function can write recursively Registry-Keys based on a JSON-Object even this JSON is nested (JSON-tree to Registry-tree).
-> This function/script is moved to GitHub!
For example you have the following JSON-Object:
$JSON = '{ "Key1" : "Value1", "Key2" : "Value2", "KeywithSubKeys": { "SubKey1" : "SubValue1", "SubKey2" : "SubValue2", "SubKeywithArray" : ["ArrayValue1", "ArrayValue2"] }, "Key3" : 1 }'
First convert this JSON to an custom PowerShell-Object:
$JSON = $JSON | ConvertFrom-Json
Now you can use the Write-JsonToRegistry function to write this to your Registry. For example I want to write the JSON-Tree to "HKEY_CURRENT_USER\SOFTWARE\RHE":
Write-JsonToRegistry -InputObject $JSON -RegistryPath "HKCU:\SOFTWARE\RHE"