24 April,2013 by Jack Vamvas
Question: How do I list all files in a directory and order the files by Creation Time in ascending order, using Powershell?
Answer: Use Powershell cmdlets – Get-ChildItem and Sort-Order to list the files in a directory .
If the item is a container, it gets the items inside the container, known as child items. Use the Recurse parameter to get items in all child containers.
The Sort-Object cmdlet sorts objects in ascending or descending order based on the values of properties of the object. In the example below, I’ve select a single property i.e CreationTime.
#An example of listing items in a directory Get-ChildItem -path "C:\projects\testing\laboratory" #An example of listing the items, filtering name and length and using sort-object Get-ChildItem -path "C:\projects\testing\laboratory"| select name,lastwritetime,CreationTime | sort-object -property CreationTime