Switch Statement with Exact Parameter
suggest change-Exact requires a whole-string match. It is case-insensitive, and it is the default when you do not pass -Wildcard or -Regex.
Example:
switch -Exact ('Condition')
{
'condition' {'First Action'}
'Condition' {'Second Action'}
'conditioN' {'Third Action'}
'^*ondition$' {'Fourth Action'}
'Conditio*' {'Fifth Action'}
}
First Action
Second Action
Third Action
The first three actions run because those strings match the input, ignoring case. The regex and wildcard patterns do not match as exact strings.
The fourth condition would match if -Regex were used. It does not match here.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents