Continue Keyword in PowerShell

One of the things that is a bit confusing for powershell beginner is theย Continueย statement. This is partially because it does not act like it might in some other languages. Next question will arise, then what does theย Continueย statement do in Windows PowerShell? the answer is it returns flow to the top of the innermost loop that is controlled by aย While,ย For, orย Foreachย statement.ย 

Example:

In the following example, program flow returns to the top of the While loop if value of $myValue variable is equal to 6. As a result, all the numbers between 1 and 10 are displayed except for 5:

Output:

The Continue keyword supports labels. A label is a name you assign to a statement in a script, so the continue will skip in the current loop and execute form theย ย assigned label location. Let we discuss more about the labels in upcoming articles.