Group-Object
Group objects by a property
Get-ChildItem -File | Group-Object -Property Extension
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Group-Object
Buckets objects. Each group has Name, Count, and Group (the members). Great for "how many of each extension".
Try this
Get-ChildItem -File | Group-Object Extension | Sort-Object Count -Descending