We help IT Professionals succeed at work.

Report on last used/accessed date

sara2000 asked
PowerShell experts out there. I have a server with several thousand folders and files which have been touched for a long time.
I would like to get a report on those folders and files. Is there any ps script that you have so I can get a report of those files and folder?
Watch Question

Most Valuable Expert 2019
Most Valuable Expert 2018
Something like this?
Get-ChildItem -Path C:\Pakete -Recurse -File |
	Select-Object -Property Name, Length, Extension, FullName, DirectoryName, LastWriteTime, CreationTime, LastAccessTime |
	Export-Csv -NoTypeInformation -Path C:\Temp\FileReport.csv

Open in new window

Most Valuable Expert 2019
Most Valuable Expert 2018

Maybe some notes to the different dates:
CreationTime is the time the object was created. This means that, for example in case of a copy, a file's CreationTime may actually be later than the LastWriteTime.
LastAccessTime is not really reliable; it can/may be updated by all kinds of background jobs, like virus scans, backups, indexing.
LastWriteTime for a file is the date when the file was last modified. But even for a 10 year old file, this obviously doesn't mean that the file isn't in use anymore, as it may be read daily from every user. For a directory, it is the date when a file or folder was added to or removed from said directory. It does not mean the date when a file was last changed in that directory; changes to existing children do not update a folders LastWriteTime attribute!
In other words: time stamps for folders are pretty much useless, which is why I excluded them in the script above.