Friday, October 11, 2024

Changing last modified and creation date or time via PowerShell

There are some situations where you need to adjust the last modified or the created flag from a file in an Windows OS system. This could be done easily via powershell via:

Run powershell as admin and then use:

 

Creation Time:

Get-ChildItem  C:\testFile1.txt | % {$_.CreationTime = ’01/11/2005 06:00:36′}

 

Last modified:

Get-ChildItem  C:\testFile1.txt | % {$_.LastWriteTime = ’01/11/2005 06:01:36′}

 

Keep noted that you might need to change the data format to your one. So if you are prefering to use the ISO date format you might wish to use something like:

Get-ChildItem  C:\testFile1.txt | % {$_.LastWriteTime = ‘2005-11-01 06:01:36’}

Otherwise it will not work as the used date do not fit the configured OS date format. However in that case you will not get an error it simply wouldn´t change the date.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles