PS
Powershell Tutorial Online

Powershell While Loop

Create the DemoWhileLoop.ps1 file with below statements

$i = 0
While ($i -lt 5)
 {
  "'$i equals $i. This is less than  5"
  $i++
 } #end while $i lt 5
When you run the DemoWhileLoop.ps1 script, you will get the following output:
$i equals 0. This is less than  5
$i equals 1. This is less than  5
$i equals 2. This is less than  5
$i equals 3. This is less than  5
$i equals 4. This is less than  5
PS C:\>