localscript/ExampleExportObject.ps1
[PSCustomObject]@{ 'RegKey' = 'SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32' 'Enable' = @{ 'Operation' = 'Set' 'ValueName' = '(Default)' 'ValueData' = $null 'ValueType' = 'String' } 'Disable' = @{ 'Operation' = 'Remove' 'Path' = 'SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}' } 'Default' = @{ 'Operation' = 'Remove' 'Path' = 'SOFTWARE\CLASSES\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}' } } | ConvertTo-Json | Set-Content -Path './private/data/ClassicContextMenu.json -Encoding unicode' [PSCustomObject]@{ 'RegKey' = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' 'Enable' = @{ 'Operation' = 'New' 'ValueName' = 'HideFileExt' 'ValueData' = 1 'ValueType' = 'DWORD' } 'Disable' = @{ 'Operation' = 'New' 'ValueName' = 'HideFileExt' 'ValueData' = 0 'ValueType' = 'DWORD' } } | ConvertTo-Json | Set-Content -Path './private/data/ExplorerHideFileExt.json' -Encoding unicode function New-JsonObject { Param( $RegKey = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced', $Operation = 'New', $ValueName, $ValueType = 'DWORD', $FileName ) [PSCustomObject]@{ 'RegKey' = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' 'Enable' = @{ 'Operation' = 'New' 'ValueName' = $ValueName 'ValueData' = 1 'ValueType' = 'DWORD' } 'Disable' = @{ 'Operation' = 'New' 'ValueName' = $ValueName 'ValueData' = 0 'ValueType' = 'DWORD' } } | ConvertTo-Json | Set-Content -Path "./private/data/$FileName.json" -Encoding unicode -NoNewline } import-csv C:\Users\jcjbr\mycsv.csv | ForEach-Object {New-JsonObject -ValueName $_.Name -FileName $_.CmdletName} |