Examples
The following example uses the return keyword to exit a function at a specific point if a conditional is met. Odd numbers are not multiplied because the return statement exits before that statement can execute.
function MultiplyEven
{ param($number) if ($number % 2) { return "$number is not even" } $number * 2
} 1..10 | ForEach-Object {MultiplyEven -Number $_}
1 is not even
4
3 is not even
8
5 is not even
12
7 is not even
16
9 is not even
20