I need to join two tables that I have created in Powershell. The problem is that out of the 5 columns they share, two columns are different in each table. How can I join these
Ok, assuming you don't have linked entries and all the records are separate you could do this:
$T2Keys = $Results2|gm|?{$_.MemberType -match "Property"}|Select -ExpandProperty Name
$T1Keys = $Results|gm|?{$_.MemberType -match "Property"}|Select -ExpandProperty Name
$KeysToAdd = $T2Keys|?{$T1Keys -notcontains $_}
$Results3 = @()
$Results3 += $Results
$KeysToAdd|%{$Results3|Add-Member $_ ""}
$Results3+=$Results2
That queries the properties of the first table to a variable. It does the same to the second table. It finds the properties that are in the second table that aren't in the first one and saves them to a variable. Then it makes an empty array, adds the first table to it, adds the missing fields, then adds the second table to it.