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"))

Video

Alternative

The PowerShell offers here a simple alternative to special programs like e.g. Attribute-Changer

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Questions / Comments