Powershell get-childitem and date modified

Datetime:2017-04-20 05:43:55         Topic: PowerShell          Share        Original >>
Here to See The Original Article!!!

Question:I can list out the files of a directory using Powershell get-childitem , but how can I display the Windows sdirectory “date modified” column as part of the recordset returned by get-childitem?

The code I’m using is :

Get-ChildItem -path "Y:\myfolder"| select name

Answer:The Powershell code you’ve presented just needs to be extended by adding another select item : lastwritetime

Get-ChildItem -path "Y:\myfolder"| select name,lastwrite

To sort by lastwritetime add a sort-object filter

Get-ChildItem -path "Y:\myfolder"| select name,lastwritetime | sort-object -property lastwritetime

To export the results to a CSV you can extent the powershell code by adding theExport-CSV cmdlet

Get-ChildItem -path "Y:\myfolder"| select name,lastwritetime | sort-object -property lastwritetime| Export-CSV -notype Y:\myfile.csv