Change File Modified Date


Using Powewrshell Set_LastWriteTime, we are able to modify a files last modifed date and time.

1
2
$date = date
(get-item c:\temp\list.txt).set_LastWriteTime($date)

To adjust the date to a day in the past just change the $date line:

1
2
$date = (date).AddDays(-10)
(get-item c:\temp\list.txt).set_LastWriteTime($date)

This just moved the date back 10 days from today. To go forward you would do:

1
2
$date = (date).AddDays(10)
(get-item c:\temp\list.txt).set_LastWriteTime($date)

,

  1. No comments yet.
(will not be published)