PowerShell Switch Statement with CaseSensitive Parameter


Example

The -CaseSensitive parameter enforces switch statements to perform exact, case-sensitive matching against conditions.

Example:

switch -CaseSensitive ('Condition')
{ 
  'condition'   {'First Action'}
  'Condition'   {'Second Action'} 
  'conditioN'   {'Third Action'}  
}

Output:

Second Action

The second action is the only action executed because it is the only condition that exactly matches the string 'Condition' when accounting for case-sensitivity.