Skip to content

Instantly share code, notes, and snippets.

@clemmesserli
Created May 1, 2020 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemmesserli/4eef2082c976861e5925bd2bcbe7483c to your computer and use it in GitHub Desktop.
Save clemmesserli/4eef2082c976861e5925bd2bcbe7483c to your computer and use it in GitHub Desktop.
SetFileTimeStamp
<#
Description: How to edit timestamps with Windows PowerShell
Single File
Get-Item C:\temp\test.txt | select Mode, Name, CreationTime, LastAccessTime, LastWriteTime | fl
$(Get-Item C:\temp\test.txt).creationtime=$(Get-Date)
$(Get-Item C:\temp\test.txt).lastaccesstime=$(Get-Date "12/24/2011 07:15 am")
Get-Item C:\temp\test.txt | select Mode, Name, CreationTime, LastAccessTime, LastWriteTime | fl
#>
$FilePath = "C:\temp"
$TimeStamp = "11/11/2019 12:00:00"
$FileList = Get-ChildItem -Path C:\temp -File -Force
foreach($File in $FileList) {
$File.CreationTime=($TimeStamp)
$File.LastAccessTime=($TimeStamp)
$File.LastWritetime=($TimeStamp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment