PowerShell: File attributes: Change date - without any tools.
As an alternative to special programs, the date of a file or folder can also be changed with PowerShell.
Change modification date (Modified on, modified)
The command get-item loads a file or folder and its properties and offers the possibility to rewrite some of the properties:
Here the setting of the modification date in one line:
$(get-item c:\temp\x.png).LastWriteTime = (Get-Date("2020-03-22 16:22"))
Alternatively, the file could of course be loaded into a variable first and the properties rewritten afterwards:
$file = get-item c:\temp\x.png
$file.LastWriteTime = (Get-Date)
(Get-Date without specifying a date uses the current date)
Change creation date (CreationTime)
$(get-item c:\temp\x.png).CreationTime = (Get-Date("2020-03-22 16:22"))
change last access (LastAccessTime)
$(get-item c:\temp\x.png).LastAccessTime = (Get-Date("2020-03-22 16:22"))
Alternative
The PowerShell offers here a simple alternative to special programs like e.g. Attribute-Changer

{{percentage}} % positive

THANK YOU for your review!
PowerShell Log-Files: Logging into a textfile - write to file
Log files in PowerShell can be created via the Out-File command, via a custom function, or via PowerShell's built-in Transcript. ... continue reading

PowerShell text file and csv read / write
PowerShell text file and csv read / write ... continue reading
PowerShell Loops and Array
An array stores multiple values, similar to a 2-column table. ... continue reading