Powershell script sort list file

It’s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date.

Sort By Name

Get-ChildItem C:\ | sort -property Name

Sort By Size

Get-ChildItem C:\ | sort -property Length

Sort By Date Modified

Get-ChildItem C:\ | sort -property LastWriteTime

You also can reorder the sort output with “-descending”
example :

Get-ChildItem C:\ | sort -property LastWriteTime -descending

Leave a Reply

Your email address will not be published. Required fields are marked *