Richard Siddaway spezza una lancia a favore del cmdlet Measure-Object, a suo dire misconosciuto.
One cmdlet that I don’t think gets used enough is Measure-Object. This enables you to find the minimum, maximum, sum and average of a set of numbers coming down the pipeline
PS> 1..12 | Measure-Object -Sum -Maximum -Minimum -Average
You can also work with properties:
PS> Get-Process | Measure-Object -Property Handles -Sum -Maximum -Minimum -Average
You don’t need to select all of the options.
PS> (Get-Process | Measure-Object -Property Handles -Average).Average
Next time you need to find the maximum, minimum, average or sum remember measure-object instead of spending time writing your own routines