PowerShell Simple Switch With Break


Example

The break keyword can be used in switch statements to exit the statement before evaluating all conditions.

Example:

switch('Condition')
{
  'Condition'
  {
    'First Action'
  }
  'Condition'
  {
    'Second Action'
    break
  }
  'Condition'
  {
    'Third Action'
  }
}

Output:

First Action
Second Action

Because of the break keyword in the second action, the third condition is not evaluated.