Get list of files whose creation date is greater than some date time

14.2k views Asked by At

I have a date 2015/05/28 I want to list all files using order by creation date whose creation date is greater than that using PowerShell. How could I do that?

I googled for it and found Get-ChildItem "C:\Users\gerhardl\Documents\My Received Files" but no idea how to compare it with creation date plus order the result by creation date.

2

There are 2 answers

0
Varvara Kalinina On BEST ANSWER
Get-ChildItem "C:\Users\gerhardl\Documents\My Received Files" | 
    Where-Object { $_.CreationTime -gt [datetime]"2014/05/28" } | 
    Sort-Object CreationTime | 
    Format-Table Name, CreationTime

String is cast to datetime if you specify [datetime] before it. You can read about comparison operators by typing help about_Comparison_Operators in PowerShell console.

0
Martin Brandl On

Just filter the output with Where-Object:

Get-ChildItem "C:\Users\gerhardl\Documents\My Received Files" | 
   Where-Object CreationTime -gt ([DateTime]::Parse('2015/05/28'))