Reputation: 38228
I have succeeded to copy and paste and execute multi-lines of code in Powershell Console when there is one single foreach and it doesn't work when there is 2 double nested foreach.
Anyone has succeeded ?
Upvotes: 1
Views: 6011
Reputation: 5862
That is possible. Copy/paste the following in your PowerShell console host:
$mytwodimarray = @(@(1, 2), @(10, 20), @(100, 200))
foreach ($outer in $mytwodimarray) {
foreach ($inner in $outer) {
"inner value $inner"
}
}
This succeeds, with the desired output:
inner value 1
inner value 2
inner value 10
inner value 20
inner value 100
inner value 200
In short, a nested loop won't cause your problem. You most likely have a syntax error in your actual code. Try running the snippet in PowerShell ISE or similar, and see if something jumps out at you.
Upvotes: 2