Forum Discussion
farism
Sep 11, 2020Copper Contributor
How to run Foreach loop twice
HI, I wonder if it's possible to run a foreach loop 2 time, for example $x=1..5
foreach ($v in $x) {
Write-Host $v
if ($foreach.current -eq $x.Count){
Write-Host "I reach the e...
- Sep 23, 2020
Use Function instead
place the Business logic in a function and pass the value to it through the code.
farism
Sep 15, 2020Copper Contributor
Thanks,
Surely I use a better Var names, but here just to make it short and easy.
anyway, the method you propose will still need to run a 2 foreach, I want to do it using 1 foreach loop
Thanks
farismalaeb
Sep 23, 2020Iron Contributor
Use Function instead
place the Business logic in a function and pass the value to it through the code.