The string value specified in the switch statement’s script block has to exactly match a condition for that condition to equal true. Despite it being unnecessary for exact matches, this would be the same as using the -exact option in a switch statement. There are other options available for use such as -wildcard which lets you use wildcards, and -regex which uses regular expressions. lets look at an example;
Tag Archives: switch statement
PowerShell Tutorial the switch statement part 1.
PowerShell’s switch statement is similar to an if statement though easier to implement when you want to evaluate numerous conditions. You can use the switch statement to automate tasks such as retrieving System event log entries and performing actions based on the type of entry, and or moving and deleting files based on their file names.