Skip to content

Instantly share code, notes, and snippets.

@alantsai
Created January 28, 2017 03:32
Show Gist options
  • Save alantsai/d1fe225fd653bff83061594d40045ab4 to your computer and use it in GitHub Desktop.
Save alantsai/d1fe225fd653bff83061594d40045ab4 to your computer and use it in GitHub Desktop.
Set Timestamp for specific file #powershell
# usage Set-FileTimeStamps -path C:Ref -date 7/1/11
# From https://blogs.technet.microsoft.com/heyscriptingguy/2012/06/01/use-powershell-to-modify-file-access-time-stamps/
Function Set-FileTimeStamps
{
Param (
[Parameter(mandatory=$true)]
[string[]]$path,
[datetime]$date = (Get-Date))
Get-ChildItem -Path $path |
ForEach-Object {
$_.CreationTime = $date
$_.LastAccessTime = $date
$_.LastWriteTime = $date }
} #end function Set-FileTimeStamps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment