Powershell While Loop

Create the DemoWhileLoop.ps1 file with below statements

Example

$i = 0
While ($i -lt 5)
 {
  "'$i equals $i. This is less than  5"
  $i++
 } #end while $i lt 5

Copy and Try it

When you run the DemoWhileLoop.ps1 script, you will get the following output:

Example

$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:\>

Copy and Try it