As I am preparing for a few of my upcoming PowerShell sessions, such as “Howto use PowerShell v3 to make your scripts X times faster” (Experts 2 Experts Virtualization Conference), I’m using a PowerShell cmdlet to time my scripts, namely the Measure-Command cmdlet. This way you can truly see the advantages of using different approaches to accomplish the same things
For example, getting all files with a specific extension can be done in a lot of different ways. By using the correct approach for that goal, you can make your scripts a lot faster! An example:
But when I use the –filter parameter instead of the –include parameter, it provides the same output but a lot faster!
Conclusion: Use the right tool for the right task
Seems logical to me :-).
It’s the same when using a filter and piping the results and using a where-clause. The first (-Filter) will process faster because you’ve got less object going through the pipeline.
Very interesting though!