Using Windows PowerShell to Manipulate Timestamps of Files

Using Windows Powershell, you can get timestamps for creation, last access, and last write times. 

Examples:

  • PS>$(Get-Item ).creationtime=$(Get-Date "mm/dd/yyyy hh:mm am/pm")
  • PS>$(Get-Item ).lastaccesstime=$(Get-Date "mm/dd/yyyy hh:mm am/pm")
  • PS>$(Get-Item ).lastwritetime=$(Get-Date "mm/dd/yyyy hh:mm am/pm")

Another thing that the Powershell can be used for is setting the timestamps to whatever value you want.  It can be future or past.

Here is an example of setting the last write time of file “test.txt” to 1-1-2020:

  • PS>$(get-item test.txt).lastwritetime=$(set-date "01/01/2020")

Networking Powershell Windows 7 Windows 2008 Server