I can't seem to figure out a way to properly skip the rest of the Process Block without completely exiting it. Take the following as an example:
Write-Error does not terminate the Process block. However, it doesn't skip the rest of the block as I intend.
Using any keywords such as break, continue, return, or throw will shut down the pipeline completely.
How exactly can I achieve something similar to the effect of "continue" in a loop?
function Test { Begin { $i = 1 } Process { if ($i -eq 10) { Write-Error 'Some Error' } Write-Host ($i++) } } cls 1..20 | Test
Write-Error does not terminate the Process block. However, it doesn't skip the rest of the block as I intend.
Using any keywords such as break, continue, return, or throw will shut down the pipeline completely.
How exactly can I achieve something similar to the effect of "continue" in a loop?