while Loop
noun
say it: “WYL LOOP” /ˈwaɪl ˈlup/
A loop that keeps repeating its steps for as long as a condition stays true, checking before each time round.
What is a while loop in PowerShell?
A while loop checks its condition before every pass and repeats the steps in its braces for as long as the answer is True. Something inside the loop must change the answer, or it never ends.
$fuel = 40
while ($fuel -lt 100) {
"Fuel at $fuel%"
$fuel += 20
}
# Fuel at 40%
# Fuel at 60%
# Fuel at 80%
In a sentence
- “Sam's while loop kept adding fuel until the tank reached 100.”
- “The launch script waits in a while loop until go.txt appears.”
Level: Apprentice · More PowerShell terms at this level
Updated