Do While

The difference between the while and do while statement is that a do while will execute your code at least 1 time before it checks the condition. It will repeat (loop) as long as the condition returns True.

Usage of do while

do {
	# your code here
} while (condition)
		

Examples

Count to 20:

$i = 1

do {
	Write-Host $i
	$i++
} while ($i -le 20)
		

A shorter notation. Don't forget the semi-colon (;) delimiter here!

$i = 1

do {Write-Host $i;$i++} 
while ($i -le 20)