由于Get-ChildItem -Path *.exe
将显示当前目录中的所有可执行文件,为什么Get-ChildItem -File -Include *.exe
不会返回相同的结果?两个命令都在同一个目录中执行,第一个命令(使用-Path)返回可执行文件的列表,但第二个命令(使用-File)不会。 (gci -File
将列出一切,包括EXE)PowerShell 3.0中的相同命令的不同结果
Get-ChildItem -File | gm #=> FileInfo
Get-ChildItem *.* | gm #=> DirectoryInfo and FileInfo
所有命令波纹管返回类型的对象的FileInfo
Get-ChildItem -File
Get-ChildItem *.* -Include *.exe
Get-ChildItem -Path *.exe
但混合 - 文件和-Include/-Exclude没有返回,即使-include正在寻找一个文件类型:
Get-ChildItem -File -Include *.exe #=> Returns nothing
我在这里错过了什么?
亚历山大你肯定有路你查询exe文件的任何exe文件,你考'GCI型滤波器-include的* .exe -Recurse'是寻找exe文件中的所有目录和子目录 – powershell 2015-04-03 13:23:35
是的,我有道路上的exe。 gci -Path * .exe返回它们的列表。运行gci -File -Recurse -Include * .exe也是如此,但它也包含子目录中的所有exes – 2015-04-03 14:34:17