The -match operator is both a comparison operator and an array operator, depending on its input object.
If it is a scalar, it returns a boolean value. If it is an array, it returns all elements of the array that match the pattern.
@($Filenames) -match '*.csv'
Use array syntax to ensure that you still get the array if Get-ChildItem returns only one file name. Otherwise, you will get $True back instead of the file name if it matches.
source share