Question:
Situation:
Get-ChildItem $Path -Filter *.dll
works for me- This works:
12345$Path = "$env:windir\system32\*"$GuyArray = @("*.dll", "*.exe")Get-ChildItem $Path -Include $GuyArray - But I cannot get this working:
12345$Path = "$env:windir\system32\*"$GuyArray = @("*.dll", "*.exe")Get-ChildItem $Path -Filter $GuyArray
Error message:
Cannot convert ‘System.Object[]’ to the type ‘System.String’ required by parameter ‘Filter’. Specified method is not supported.
Questions:
- Does this mean that
-Include
supports multiple values, but-Filter
only allows one value? - If the above explaination is correct, is there a way I could have discovered this from
Get-Help gci
?
Answer:
Does this mean that
-Include
supports multiple values, but-Filter
only allows one value?
Yes.
If the above explaination is correct, is there a way I could have discovered this from
Get-Help gci
?
Yes, but you do not get much information by Get-Help gci -Parameter Filter
. But you still can see it is a string, not an array. As for the details, Filter
is a provider-specific filter. Get-Help gci
cannot tell you anything about implementation in a particular provider. In theory, Get-Help FileSystem
(help about this provider) should have explained this.
P.S. Also note that this filter rather uses CMD wildcard rules than PowerShell wilcard rules.