AlanTsai
1/28/2017 - 3:32 AM

Set Timestamp for specific file #powershell

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