The Christian answer is what you should do in your situation. There is no need to get two lists. Remember one thing in PowerShell - work with objects until the last step. Do not try to get their properties, etc. Until you use them.
But for the general case, when you have two lists and you want to have Foreach
over two:
You can do what Foreach does:
$a = 1, 2, 3 $b = "one", "two", "three" $ae = $a.getenumerator() $be = $b.getenumerator() while ($ae.MoveNext() -and $be.MoveNext()) { Write-Host $ae.current $be.current }
Or use a regular for
loop with $a.length
, etc.
source share