PowerShell for Windows Admins

Dec 30 2018   7:39AM GMT

Change file times

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

When a file is created, accessed or modified that time is recorded. This is how to change file times.

There are three properties to consider:

CreationTime

LastAccessTime

LastWriteTime

 

Just to add to the fun there are UTC (GMT in real world) times as well:

CreationTimeUtc

LastAccessTimeUtc

LastWriteTimeUtc

If you need to change a property its a set operation. For instance

Get-ChildItem -Path x9.txt | foreach {$_.LastWriteTime = ($_.LastWriteTime).AddHours(6)}

 

Substitute the appropriate property as required. If you change a property the UTC version is changed in step – accounting for timezone differences

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: