Created
April 14, 2017 12:50
-
-
Save milesgratz/b13bb116df7bd3636766d62fb3a2d96b to your computer and use it in GitHub Desktop.
Using -match with array of objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Source = "txt","csv","pdf","xlsx","docx" | |
$Find = "csv","pdf" | |
$Source | ForEach-Object { | |
# does not work | |
# -match cannot find item in array | |
If ($_ -match $Find) | |
{ | |
$_ | |
} | |
# works | |
# creates (csv|pdf) join | |
If ($_ -match ($Find -join "|")) | |
{ | |
$_ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment