Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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