Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell:get childitem不';不适用于过滤器_Powershell_Filter_Get Childitem - Fatal编程技术网

Powershell:get childitem不';不适用于过滤器

Powershell:get childitem不';不适用于过滤器,powershell,filter,get-childitem,Powershell,Filter,Get Childitem,我在d下有3个ps1文件: -a--- 6/19/2015 2:52 PM 104 Untitled1.ps1 -a--- 6/19/2015 2:56 PM 204 Untitled2.ps1

我在d下有3个ps1文件:

-a---         6/19/2015   2:52 PM        104 Untitled1.ps1                                                                                                                       
-a---         6/19/2015   2:56 PM        204 Untitled2.ps1                                                                                                                       
-a---         6/16/2015   1:17 PM       3073 Untitled3.ps1  
我可以使用get childitem检索它们:

get-childitem d:\
但这失败了:

 get-childitem d:\ -Force -Include *.ps1
此命令不显示任何内容。为什么?我只想过滤掉.ps1文件。我的命令有什么问题吗

Include参数仅在命令包含 递归参数或指向目录内容的路径, 例如C:\Windows*,其中通配符指定 C:\Windows目录的内容

资料来源:

您可以改用-Filter参数:

Get-ChildItem-Path'd:\'-Filter'*.ps1'
或者,如果需要筛选多个扩展名,请使用通配符:

Get-ChildItem-Path'd:\*'-包括'*.ps1','*.bat'

如果我想过滤两种类型的文件,“ps1”和“bat”,该怎么办。如何编写此命令?