You are currently viewing PowerShell Measure-Object Cmdlet

PowerShell Measure-Object Cmdlet

PowerShell Measure-Object Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed ForEach-Object cmdlet in PowerShell.

https://cloudaffaire.com/powershell-foreach-object-cmdlet/

In this blog post, we will discuss Measure-Object cmdlet in PowerShell. You can use Measure-Object cmdlet to perform calculation on a collection of objects. Measure-Object performs three types of measurements, depending on the parameters in the command. You can use Measure-Object cmdlet to calculate the count of the objects or count of object based on certain property. If the object is of type numeric, you can use Measure-Object cmdlet to calculate the Minimum, Maximum, Sum, Standard Deviation and Average of numeric values. If the object is of type string, you can use Measure-Object to count the number of lines, words, and characters.

Measure-Object Cmdlet Syntax:

Measure-Object Cmdlet Argument List:

  • AllStats: Indicates that the cmdlet displays all the statistics of the specified properties.
  • Average: Indicates that the cmdlet displays the average value of the specified properties.
  • Character: Indicates that the cmdlet counts the number of characters in the input objects.
  • IgnoreWhiteSpace: Indicates that the cmdlet ignores white space in character counts. By default, white space is not ignored.
  • InputObject: Specifies the objects to be measured. Enter a variable that contains the objects, or type a command or expression that gets the objects.
  • Line: Indicates that the cmdlet counts the number of lines in the input objects.
  • Maximum: Indicates that the cmdlet displays the maximum value of the specified properties.
  • Minimum: Indicates that the cmdlet displays the minimum value of the specified properties.
  • Property: Specifies one or more properties to measure. If you do not specify any other measures, Measure-Object counts the objects that have the properties you specify.
  • StandardDeviation: Indicates that the cmdlet displays the standard deviation of the values of the specified properties.
  • Sum: Indicates that the cmdlet displays the sum of the values of the specified properties.
  • Word: Indicates that the cmdlet counts the number of words in the input objects.

PowerShell Measure-Object Cmdlet:

Calculate Count, Sum, Average, Maximum And Minimum Values From A Collection Of Numeric Objects In PowerShell:

Calculate Word Count, Line Count And Character Count From A Collection Of String Objects In PowerShell:

Perform Calculation On The Output Of A Cmdlet In PowerShell:

Hope you have enjoyed this article. In the next blog post, we will discuss Tee-Object cmdlet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply