How Can We Help?
< Back
You are here:
Print

Use the ‘faster’ methods

The following filtering example with a Where-Object is quite common.

Since PowerShell v4 there is now a Where method available. And this method tends to be faster than the equivalent Where-Object cmdlet.

The previous snippet can now be coded as this.

Note that this option is not limited to the Where method, you can also do

Which is basically the same as

The Where method can also take an addition parameter. This for example a handy way to create two variables, one with powered on and one with powered off VMs.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Table of Contents