There are situations where we could group the objects that were given as output so that we could handle each group better, or simply so that we get a more organized output. In this recipe, we will look at passing the output of one cmdlet through the pipeline to Group-Object and group the output based on a property.
Grouping the output
How to do it...
To group objects based on a property, we will use the Get-ChildItem cmdlet on the files that we created for use in this book:
- Navigate to the location where you created or downloaded the files:
PS> Set-Location ~/random
- List out only the files (exclude the directories):
PS> Get-ChildItem -Path . -File
Alternatively, you can use the shorthand version:
PS> gci -File...