Sep 11 2020 02:34 AM
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 end and will change the values"
$x=100..105
$foreach.reset()}
}
"End of Scripts"
The Above script will read the value from X which is 1 till 5, and do some logic in the Foreach loop, But what I am stuck in is after all the execution of Foreach finished, I want to re-execute the same logic but with a different value of $X.
Any Idea about this.
Thanks
Sep 14 2020 05:30 AM
Sep 15 2020 04:03 AM
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
Sep 23 2020 02:21 AM
SolutionUse Function instead
place the Business logic in a function and pass the value to it through the code.
Sep 23 2020 02:21 AM
SolutionUse Function instead
place the Business logic in a function and pass the value to it through the code.