Created
January 28, 2017 03:32
-
-
Save alantsai/d1fe225fd653bff83061594d40045ab4 to your computer and use it in GitHub Desktop.
Set Timestamp for specific file #powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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