【发布时间】:2014-12-21 12:18:32
【问题描述】:
情况:
Get-ChildItem $Path -Filter *.dll为我工作-
这行得通:
$Path = "$env:windir\system32\*" $GuyArray = @("*.dll", "*.exe") Get-ChildItem $Path -Include $GuyArray -
但我无法正常工作:
$Path = "$env:windir\system32\*" $GuyArray = @("*.dll", "*.exe") Get-ChildItem $Path -Filter $GuyArray
错误信息:
无法将“System.Object[]”转换为参数“Filter”所需的类型“System.String”。不支持指定的方法。
问题:
- 这是否意味着
-Include支持多个值,而-Filter只允许一个值? - 如果上面的解释是正确的,我有没有办法从
Get-Help gci发现这个?
【问题讨论】:
-
第 3 项应该是
Get-ChildItem $Path -Filter $GuyArray吗? -
是的,我弄错了,#3 应该是 -Filter 而不是 -Include
标签: powershell filter