internal/functions/Merge-Table.ps1
##CREDIT https://stackoverflow.com/questions/8800375/merging-hashtables-in-powershell-how Function Merge-Hashtables([ScriptBlock]$Operator) { $Output = @{} ForEach ($Hashtable in $Input) { If ($Hashtable -is [Hashtable]) { ForEach ($Key in $Hashtable.Keys) {$Output.$Key = If ($Output.ContainsKey($Key)) {@($Output.$Key) + $Hashtable.$Key} Else {$Hashtable.$Key}} } } If ($Operator) {ForEach ($Key in @($Output.Keys)) {$_ = @($Output.$Key); $Output.$Key = Invoke-Command $Operator}} $Output } |