且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

get-childitem 中 -include 和 -filter 的区别

更新时间:2023-12-04 11:14:28

  1. Filter 参数由提供者实现.它是有效的,因为在检索对象时适用.Get-PSprovider commandlet 显示实现过滤器"参数的提供程序.例如,我的上只有两个提供者系统:ActiveDirectory 和文件系统

  1. Filter parameter is implemented by provider. It is efficient because applies when retrieving the objects. Get-PSprovider commandlet shows providers that implement 'filter' parameter. For example, there are only two providers on my system:ActiveDirectory and FileSystem

Include 参数由 Powershell 实现.它仅与 Recurse 参数结合使用(如 MSDN 描述的 这里).

Include parameter is implemented by Powershell. It only works in conjunction with Recurse parameter (as MSDN describes here).

有趣的是:

get-childitem -path Desktop\Extras\ -include *.txt

什么都不返回

get-childitem -path Desktop\Extras\* -include *.txt

返回 *.txt 文件列表

returns list of *.txt files

也许这些只是实现的细微差别.

Maybe these are just nuances of the implementation.

另见这篇优秀的博文:http://tfl09.blogspot.com/2012/02/get-childitem-and-theinclude-and-filter.html