Difference between -include and -filter in get-childitem

后端 未结 2 374
忘掉有多难
忘掉有多难 2020-12-17 09:06

Can someone please explain the difference between -Include and -Filter options in the Get-ChildItem command .

Below are the two

2条回答
  •  旧时难觅i
    2020-12-17 09:29

    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

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

    3. It's interesting that:

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

      returns nothing

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

      returns list of *.txt files

    Maybe these are just nuances of the implementation.

    Also see this excellent blog post: http://tfl09.blogspot.com/2012/02/get-childitem-and-theinclude-and-filter.html

提交回复
热议问题