Functions/array.ps1
function Merge-Array( [object[]]$array, [Parameter(Mandatory = $true)] [object[]]$arrayToMerge ) { if ($array -ceq $null) { return $arrayToMerge } $filteredList = @() foreach ($property in $array) { if ($property -isnot [string]) { $filteredList += $property.PSObject.properties.name continue } $filteredList += $property } foreach ($item in ($arrayToMerge | Where-Object {($_.PSObject.Properties.Name -CNotIn $filteredList )})) { $array += $item } return $array } |