Measure-Object
noun
say it: “MEZH-er OB-jekt” /ˈmɛʒər ˈɑbdʒɛkt/
A PowerShell command that counts the objects sent to it and can add up, average or find the largest of a property.
What does Measure-Object do?
Measure-Object counts the objects that come down the pipeline. Give it a property, such as Length, and -Sum, -Average, -Maximum or -Minimum, and it works those out too. Its answer is an object, so .Sum and .Count read one number from it.
Get-ChildItem -Recurse -File | Measure-Object Length -Sum -Maximum
In a sentence
- “Piping the files into Measure-Object told Sam there were eighteen of them.”
- “Measure-Object Length -Sum added up the size of every file on the drive.”
Level: Apprentice · More PowerShell terms at this level
Updated