Forum Discussion

farism's avatar
farism
Copper Contributor
Sep 11, 2020
Solved

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...
  • farismalaeb's avatar
    farismalaeb
    Sep 23, 2020

    farism 

    Use Function instead

    place the Business logic in a function and pass the value to it through the code.

     

Resources