Grouping and measuring
Group-Object
is a powerful command that allows you to group objects together based on a property or expression.
Measure-Object
supports several simple mathematical operations, such as counting the number of objects, calculating an average, calculating a sum, and so on. Measure-Object
also allows characters, words, or lines to be counted in text fields.
The Group-Object command
The Group-Object
command shows a group and count for each occurrence of a value in a collection of objects.
Given the sequence of numbers shown, Group-Object
creates a Name
that holds the value it is grouping, a Count
as the number of occurrences of that value, and a Group
property as the set of similar values:
PS> 6, 7, 7, 8, 8, 8 | Group-Object
Count Name Group
----- ---- -----
1 6 {6}
2 7 {7, 7}
3 8 {8, 8, 8}
The Group
property...