It is time for another simple cmdlet, which will build toward the Taking actions on the returned objects recipe. In this recipe, we will sort the output objects to meet our requirements.
Sorting the output
How to do it...
We will continue using the directory and the files we created for this book. If all of your files are of size zero bytes, download a few files with content. The file type does not matter:
- List out the files in the directory:
PS> Get-ChildItem -Path .
- Filter the output so that you have only files:
PS> Get-ChildItem -Path . -File
- Pipe the object to the Sort-Object cmdlet to sort the output based on the file size:
PS> Get-ChildItem -Path . -File | Sort-Object -Property Length
- The shorthand for...