'Error trying to merge 2 variables into one

I have a problem when I try to merge 2 variables into one. Example:

$MyA = @{
   foo = 1..10
   bar = 2,4,6,8,10,12,14,16,18,20
   }
 $MyB = @{
   foo = 1..30
   bar = ""
   }

Foreach ($_ in $MyA) {Where $MyB.foo -eq $_.foo;  $MyB.bar = $_.bar}

What I want to do is: Insert $MyA.bar into $MyB.bar where the property foo matches.... But it ends up with this error message: Where-Object : A positional parameter cannot be found that accepts argument 'System.Object[]'.

What I want to end up with is something like this:

$MyB
foo bar
--------
1   2
2   4

etc. until foo is grater than 10 then bar should be empty Please help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source