Sunday, June 19, 2016

Setting a file's creation or modification date with PowerShell

Windows files each have a creation date and a "last modified" date, but those properties can easily be modified. Any user that can write to the file can set the creation, last-write, or last-access time to anything at all. That can be accomplished with the .NET methods SetCreationTime, SetLastWriteTime, and SetLastAccessTime, respectively.

You can use those without writing a .NET program. Just open PowerShell and type something like this:
[System.IO.File]::SetCreationTime("C:\America.doc", (Get-Date "7/4/1776"))

No comments:

Post a Comment