Grouping Folder Items by Extension (and more)

by Jan 10, 2009

Group-Object is a very powerful cmdlet as it takes one or more object properties and uses them to group the items. To get a quick overview of just how many different files are stored in a folder, use the file object's extension property:

Dir $env:windir | Group-Object Extension | Sort-Object Count

Grouping works for all object types. For example, if you want to get an overview of the available cmdlets, use ‘Get-Command‘ and group the result by verb or noun:

Get-Command | Group-Object Verb | Sort-Object Count
Get-Command | Group-Object Noun | Sort-Object Count

Or, you can group all aliases by their definition:

Dir alias: | Group-Object definition | Sort-Object Count