(Get-Item "<file_path>").CreationTime=("3 August 2019 17:00:00")
(Get-Item "<file_path>").LastWriteTime=("3 August 2019 17:00:00")
(Get-Item "<file_path>").LastAccessTime=("3 August 2019 17:00:00")
exercise: now do it for every file in a directory and subdirectories. Tip. use recursion.
These PowerShell commands are used to modify the file timestamps (creation time, last write time, and last access time) of a specified file. Let's break down each line:
-
(Get-Item "<file_path>").CreationTime=("3 August 2019 17:00:00")
:Get-Item "<file_path>"
: This part retrieves information about the specified file (specified by<file_path>
)..CreationTime=("3 August 2019 17:00:00")
: This part sets the creation time of the file to the specified date and time, in this case, "3 August 2019 17:00:00".
-
(Get-Item "<file_path>").LastWriteTime=("3 August 2019 17:00:00")
:- Similar to the first line, this command sets the last write time of the file to "3 August 2019 17:00:00".
-
(Get-Item "<file_path>").LastAccessTime=("3 August 2019 17:00:00")
:- This command sets the last access time of the file to "3 August 2019 17:00:00".
In summary, these commands are adjusting the creation time, last write time, and last access time of a specified file to the same specified date and time, which is "3 August 2019 17:00:00".