PS
Powershell Tutorial Online

Powershell For Loop


this way you can iterate list/collection using for.

for ($i = 0; $i -lt $myLists.Count; $i++)
{
  $list = $myLists[$i];
  # ...
}

this way you can iterate collection using foreach.
$collection = @(1, 2, 3, 4, 5)
foreach ($i in $collection)
{
Write-Host $i
}

Putting the lines in a single string

$lines = ''
for ($i=0; $i -lt 5; $i++)
{
$lines += "The current value of i is $i`n"
}
$lines