Check files and folder last time accessed in PowerShell

How to check last time a file was accessed?

How to check last time a folder was accessed?



When files and folders are just sitting on a shared folder and just occupying space for an unknown reason, such questions will easily pop.

If there's a need to check files and folders, last write time or last accessed time PowerShell can be very handy.


PowerShell codes below will be able to check files and folders, for last write time or last accessed time.

Code below is from Technet:
http://technet.microsoft.com/en-us/library/e811c7ac-c793-4dc2-82a0-92d08b0f660b

$(Get-Item c:\scripts).lastaccesstime


It will check the last access time for the specified parent folder path.

Code below will list all the:

  Folder and Sub folders plus last write time for each folder. (list folders only)

Get-ChildItem -Recurse "D:\powershell scripts"  | ?{ $_.PSIsContainer } | Select-Object FullName,lastwritetime

Code below will list all the:

 Files and folder plus last write time for each folder and files. (folders and files)

Get-ChildItem  -Recurse  -Path "D:\powershell scripts\"  $_.PSIsContainer|  Select-Object FullName, LastWriteTime

Below code will list all the:

 Files in every folder, which includes LastwriteTime and its file name. (files only)

Get-ChildItem -Path "D:\powershell scripts" $_.LastWriteTime -Recurse

Folder name has space in between, need enclosed path in quotation marks.


List all directories display result in descriptive format:

Get-ChildItem "D:\powershell scripts\" -Recurse | where {$_.PSIsContainer -eq 'Directory'}


Cheers!!! Till next time!!!


==============================

Free Android Apps:


Divine Mercy Chaplet Guide:

https://play.google.com/store/apps/details?id=com.dmercyapp


Educational App for Android Kids:

https://play.google.com/store/apps/details?id=com.letsmultiply


Catholic Rosary Guide:



Android Divine Mercy Chaplet Guide  
https://play.google.com/store/apps/details?id=com.dmercyapp 

Comments

Popular posts from this blog

Unable to install Teamviewer on Windows 7 and Windows 8

WMIC get computer name