How it works...
What we did in this recipe was certainly non-intuitive, considering that we could use just Where-Object along with Get-ChildItem. However, the intention of this recipe was to demonstrate the use of Group-Object. The Group-Object cmdlet creates groups based on the criteria we specify, and names the groups on the criteria. In our case, the criteria for grouping was the extension, and so the names of the groups were the extensions.
Each of these groups contains its elements, which are objects in themselves. If we simply want the count and the names of the groups, we use the NoElement parameter. If we want only the elements, we use the ExpandProperty parameter of the Select-Object cmdlet and expand all of the elements. The elements ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access