Variable $a Output below, Column names: VmName, RG, CurrentSKU, OS
VmName, RG, CurrentSKU, OS
VM1, RG1, DS2_v2, Windows
VM2, RG2, DS3_V3, Linux
VM3, RG3, F4S, Windows
VM4, RG4, DS2_v2, Linux
Variable $b Output below, Column names: OldSKU, newSKU
OldSKU, newSKU
DS2_v2, D2as_v4
F2s, F2sv2
DS3_V3, D2as_v4
Using Powershell I would like the output like below,
VmName, RG, CurrentSKU, newSKU, OS,
VM1, RG1, DS2_v2, D2as_v4, Windows
VM2, RG2, DS3_V3, D2as_v4, Linux
VM3, RG3, F4S, F2sv2, Windows
VM4, RG4, DS2_v2, D2as_v4, Linux
quick help on this please.
2
Answers
Use
Group-Object
to create a hashtable with the SKU mappings:Then use
Select-Object
to attach a newnewSKU
property with the mapped value:$c
now contains a new list of objects like the one you describe:I create tables $a and $b to test code