JSON to Registry: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
''This PowerShell function can write recursively Registry-Keys based on a JSON-Object even this JSON is nested (JSON-tree to Registry-tree).'' | ''This PowerShell function can write recursively Registry-Keys based on a JSON-Object even this JSON is nested (JSON-tree to Registry-tree).'' | ||
+ | <span style="font-size:20px;"><span style="color:red">'''-> This function/script is moved to [https://github.com/R-Studio/PSTools GitHub]!'''</span></span><br> | ||
Zeile 22: | Zeile 23: | ||
For example I want to write the JSON-Tree to "HKEY_CURRENT_USER\SOFTWARE\RHE": | For example I want to write the JSON-Tree to "HKEY_CURRENT_USER\SOFTWARE\RHE": | ||
<source lang="powershell">Write-JsonToRegistry -InputObject $JSON -RegistryPath "HKCU:\SOFTWARE\RHE" </source> | <source lang="powershell">Write-JsonToRegistry -InputObject $JSON -RegistryPath "HKCU:\SOFTWARE\RHE" </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Aktuelle Version vom 16. Oktober 2020, 12:54 Uhr
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"