-contiene o-coincide con varios valores
Tengo que filtrar mis resultados por ciertas cadenas e intenté hacerlo con-match
y-contains
.
-match
funciona si solo tengo un valor para filtrar, pero no con una matriz.-contains
ni funciona con una cadena ni con una matriz de cadenas
¿Por qué no funciona con varios valores? Especialmente el-contains
. ¿O hay otra manera fácil de resolverlo?
$Folder = 'C:\Test'
$filterArray = @('2017-05', '2017-08')
$filter = '2017-05'
## test with -MATCH
## working with one match string
Get-ChildItem -Path $Folder -Recurse -Include *.txt |
Where { $_.FullName -match $filter } |
ForEach-Object { $_.FullName }
## NOT working with match string array - no results
Get-ChildItem -Path $Folder -Recurse -Include *.txt |
Where { $_.FullName -match $filterArray } |
ForEach-Object { $_.FullName }
## test with -CONTAINS
## NOT working with one contains string - no results
Get-ChildItem -Path $Folder -Recurse -Include *.txt |
Where { $_.FullName -contains $filter } |
ForEach-Object { $_.FullName }
## NOT working with contains string array- no results
Get-ChildItem -Path $Folder -Recurse -Include *.txt |
Where { $_.FullName -contains $filterArray } |
ForEach-Object { $_.FullName }