19 April,2017 by Tom Collins
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 the Export-CSV cmdlet
Get-ChildItem -path "Y:\myfolder"| select name,lastwritetime | sort-object -property lastwritetime| Export-CSV -notype Y:\myfile.csv
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |