PowerShell Simple Switch with Default Condition


Example

The Default keyword is used to execute an action when no other conditions match the input value.

Example:

switch('Condition')
{
  'Skip Condition'
  {
    'First Action'
  }
  'Skip This Condition Too'
  {
    'Second Action'
  }
  Default
  {
    'Default Action'
  }
}

Output:

Default Action