For loops can be used (just like in any other programming language) to have a set process run for a finite number of times.
The structure of a for loop looks like this:
for (initial value; run until condition; repeat)
To run a for loop in Powershell, use the following example which prints out the first 5 numbers:
for ($i = 1; $i -lt 6; $i++) { Write-Host $i }
Output:
1
2
3
4
5
1
2
3
4
5
No comments:
Post a Comment