I am trying to find .sql files in a folder and filtering them based on the last write time. Based on the last write time I got 4 files as output.
TestScript10.sql
TestScript5.sql
TestScript6.sql
TestScript7.sql
Now when my command tries to do sort-object I am seeing Testscript10 at the top instead of TestScript5, how do I fix this issue?
My Code
$File= Get-ChildItem $FileLocation -Filter *.sql | Where-Object {$_.LastWriteTime -gt $datetime} | Sort-Object Name
$File
Output
[DBG]: PS SQLSERVER:\>> $File
Directory: C:\SQLScripts
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 5/22/2014 10:20 AM 61 TestScript10.sql
-a--- 5/22/2014 10:16 AM 60 TestScript5.sql
-a--- 5/22/2014 10:24 AM 66 TestScript6.sql
-a--- 5/22/2014 10:10 AM 24 Testscript7.sql