continue
verb
say it: “kun-TIN-yoo” /kənˈtɪnju/
A command that skips the rest of a loop's steps for this item and moves on to the next one.
What does continue do in a PowerShell loop?
continue skips the rest of this pass of a loop, and the loop goes on with the next item. With an if in front, it passes over the items you don't want. Inside ForEach-Object, return does the same job.
foreach ($song in Import-Csv playlist.csv) {
if ($song.Liked -eq 'no') { continue }
$song.Title
}
# Night Launch
# Solar Wind (Static Again was skipped)
# ...
In a sentence
- “continue passes over every song Sam hasn't liked.”
- “In the log reader, continue skips the note lines that start with #.”
Level: Apprentice · More PowerShell terms at this level
Updated