Skip to content

Instantly share code, notes, and snippets.

@shaneis
Created October 20, 2017 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneis/0f742b09b6655342a03925999ceb05de to your computer and use it in GitHub Desktop.
Save shaneis/0f742b09b6655342a03925999ceb05de to your computer and use it in GitHub Desktop.
Using if and match to check a string
$fileNames | ForEach-Object -Process {
if ($_ -match 'Index') {
"Use index on: $_"
} elseif ($_ -match 'Stats') {
"Use stats on: $_"
} elseif ($_ -match 'Backups') {
"Use backup on: $_"
} elseif ($_ -match 'Restores') {
"Use restores on: $_"
} elseif ($_ -match 'Checkdbs') {
"Use checkdbs on: $_"
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment