July 2017
Intermediate to advanced
648 pages
31h 9m
English
First we create a variable named $i with a value of 1 and then create a loop using the Do While operator. The loop will run until $i is less or equal to 20. Within the loop a text string is written to the console with a text Value: and the value of $i.
$i = 1
Do {
Write-Host "Value: $i" $i++ Start-Sleep -Milliseconds 200
}
While ($i -le 20)
As this is a basic example on how the debugger can be used, this method would be helpful for production when executing scripts. The debugger mode can be used when the script is running by pressing Ctrl + Break or Ctrl + B. When breaking the script, it will look like the following screenshot:
We can see that the script called loop.ps1 is stopped and has entered debug mode. When pressing ...
Read now
Unlock full access