PowerShell: Loops

Example: For Loop - simple counter


	For ($i=0; $i -le 5; $i++) 
	{
		$i
	}
	

Output:

  0
  1
  2
  3
  4
  5


Example: For Loop


	For ($i=0; $i -le 10; $i++) 
	{
		"1 * $i = " + (1 * $i)
	}
	

Output:

for Loop in PowerShell


Example: For Loop - Loop through an Array


	$employees = @("Paul Smith","Mary Jones","Frank Hill","Amy Rodgers")
	For ($i=0; $i -lt $employees.Length; $i++) {
		$employees[$i]
		}
	

Output:

  Paul Smith
  Mary Jones
  Frank Hill
  Amy Rodgers