Where-Object inside Foreach-object -parallel

29 views Asked by At

I have two datatables $dtA and $dtB. table $dtA contains about 10,000 rows. At any given point in time, table $dtB can have 1 - say 80 rows in it, which are logically linked via key column named dtKeyColumn. I am not able to filter out $dtA inside a parallel loop processing rows in $dtB

now my script looks something like this

$dtA
$dtB | foreach-parallel {
$p = $dtA | where-object {$_.dtKeyColumn -eq $PSItem.dtKeyColumn}
# $p = $dtA | where-object {$dtA.dtKeyColumn -eq $PSItem.dtKeyColumn}
# i have tried both above

....

# do some work using $p
....

}

$_.dtKeyColumn -eq $PSItem.dtKeyColumn will always be true since they are referring to the same value

how can i make this work ?

is there an alternative like a SQL inner join between the two tables ?

0

There are 0 answers