Continue

Return to top of a program loop immediately.

In a For, ForEach or While loop you can add a continue statement to jump to the top of the innermost loop.

Choose the conditions under which you call the continue statement carefully, as it is easy to create an infinite loop.

Example

Count to 10 but miss out the number 5:

 PS> $i =0
     while ($i -lt 10)
         {
           $i +=1 
           if ($i -eq 5) {continue}
           Write-Host $i
         }

“Just don't give up trying to do what you really want to do. Where there is love and inspiration, I don't think you can go wrong” ~ Ella Fitzgerald

Related:

Break statement
ForEach-Object - (foreach) Loop for each object in the pipeline
ForEach - Loop through values in the pipeline
For - Loop through items that match a condition
While Loop while a condition is True


© Copyright SS64.com 1999-2013
Some rights reserved