I am trying to update a number of values in $Table1 from another $Table2.
Say I have $Table1 (in this case an imported CSV file):
Model ModelID Blah
abc 0 Blah
ghi 0 Blah
mno 0 Blah
and I have $Table2 (in this case, obtained from a data source):
name id
abc 11
def 12
ghi 13
jkl 14
mno 15
pqr 16
etc.
I am trying to update the values in $Table1."ModelID" from $Table2."id"
WHERE $Table1."Model" = $Table2."name"
In SQL, I would do something like:
UPDATE $Table1
SET ModelID = $Table2."id"
WHERE $Table1."Model" = $Table2."name"
How do I do conditional updates based on joins on columns in a Variable in PowerShell?
I was looking at:
-replace... (I can't seem to do conditional replaces based on joins)
Add-Member -MemberType NoteProperty "modelID" -Value ... (again, I can't seem to set the value based on joins)
foreach($item in $Table1)
{
$Table1."ModelID" = $Table2."id"
where ?????
}.. (again, I can't seem to set the value based on joins)
Am I over-egging the pudding here?