Get-ChildItem -Filter数组 [英] Get-ChildItem -Filter Array
问题描述
$ b $ ol
Get-ChildItem $ Path -Filter * .dll $ c
> $ Path =$ env:windir \system32\ *
$ GuyArray = @(* .dll,* .exe)
Get-ChildItem $ Path - 包括$ GuyArray
但是我无法得到这个工作:
$ Path =$ env:windir \system32\ *
$ GuyArray = @(*。dll,*。 )
Get-ChildItem $ Path -Filter $ GuyArray
$ p
$ b
无法将'System.Object []'转换为'System .String'参数'Filter'需要。不支持指定的方法。
问题:
- 这是否意味着
-Include
支持多个值,但是-Filter
只允许一个值? - 如果上面的解释是正确的,有没有一种方法可以从
Get-Help gci
? 中找到 Get-ChildItem $Path -Filter *.dll
works for meThis works:
$Path = "$env:windir\system32\*" $GuyArray = @("*.dll", "*.exe") Get-ChildItem $Path -Include $GuyArray
But I cannot get this working:
$Path = "$env:windir\system32\*" $GuyArray = @("*.dll", "*.exe") Get-ChildItem $Path -Filter $GuyArray
- 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
?
这是否意味着
-Include
支持多个值,但是-Filter
只允许一个值?
是的。
$ b
如果上面的解释是正确的,有没有一种方法可以从
Get-Help gci
?
是的,但是您没有通过 Get-帮助gci -Parameter Filter
。但你仍然可以看到它是一个字符串,而不是一个数组。至于细节, Filter
是一个提供程序特定的过滤器。 Get-Help gci
不能告诉你任何有关在特定提供程序中实现的信息。从理论上讲, Get-Help FileSystem
(关于这个提供者的帮助)应该已经解释了这一点。
另外请注意,这个过滤器比PowerShell wilcard规则更使用CMD通配符规则。
Situation:
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?
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.
这篇关于Get-ChildItem -Filter数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!