header image

Think outside the box

Posted by: | August 7, 2018 Comments Off on Think outside the box |

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

under: PowerShell

Comments are closed.

Categories