Filter is Faster Than Include

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!


Posted Feb 22 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.