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