Grouping and measuring
Group-Object
is a powerful utility that allows you to group objects together based on similar values.
Measure-Object
supports a number of simple mathematical operations, such as counting the number of objects, calculating an average, calculating a sum, and so on. It 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
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 may be removed using the NoElement
parameter, which simplifies the output from...