PowerShell Switch statement Switch Statement with Wildcard Parameter

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The -Wildcard parameter allows switch statements to perform wildcard matching against conditions.

Example:

switch -Wildcard ('Condition')
{ 
    'Condition'           {'Normal match'}
    'Condit*'             {'Zero or more wildcard chars.'} 
    'C[aoc]ndit[f-l]on'   {'Range and set of chars.'}  
    'C?ndition'           {'Single char. wildcard'}
    'Test*'               {'No match'} 
}

Output:

Normal match
Zero or more wildcard chars.
Range and set of chars.
Single char. wildcard


Got any PowerShell Question?