Filter is Faster Than Include

by Feb 22, 2010

A number of cmdlets provide two parameters that seem to work very similar: -filter and -include:

Dir $env:windir filter *.log
Dir $env:windir -include *.log

If you have a choice, you should always pick -filter. For starters, it is much faster (4x and more) and secondly, -include only works when combined with -recurse. -filter always works.

So why is there -include at all? Because not all providers support -filter. For example, you are limited to -include when you list registry content.

Twitter This Tip! ReTweet this Tip!