PowerShell for Windows Admins

Aug 7 2018   8:18AM GMT

Think outside the box

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

One of PowerShell’s great strengths is that there are often a number of ways to achieve the same endpoint. It’s also a great weakness as newcomers are confused as to which approach to adopt and “experts” will tell you that you should only use approach X. You need to think outside the box sometimes.

Last time I used summing the contents of an array to demonstrate the speed of various options.

There is another way to sum an array:

1..1000 | Measure-Object -Sum | select -ExpandProperty Sum

If you measure the speed its about the same as foreach method

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: