Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using the -regex with the switch operator
$fileNames | ForEach-Object -Process {
switch -regex ($_) {
'Index' { "Use index on: $_" }
'Stats' { "Use stats on: $_" }
'Backups' { "Use backups on: $_" }
'Restores' { "Use restores on: $_" }
'Checkdbs' { "Use checkdbs on: $_" }
Default { "didn't match anything..." }
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.