functions/public/Merge-Hashtables.ps1
function Merge-Hashtables { [CmdletBinding()] param ( [Parameter(ValueFromPipeline)] $hash ) $output = @{} $subHash = @{} foreach ($hash in $input) { if ($hash -is [Hashtable]) { foreach ($key in $hash.Keys) { if ($key -ne "_type_") { $output.$key = $hash.$key } else { foreach ($subKey in $hash[$key].Keys) { $subHash.$subKey = $hash[$key].$subKey } } } } } $output.Add("_type_", $subHash) return $output } |