Question:
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.
Answer:
1 2 3 4 5 |
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.