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



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!

Publication: 2022-05-03 from Bernhard | Übersetzung Deutsch |🔔 | Comments:0

PowerShell Log-Files: Logging into a textfile - write to file | PowerShell | PowerShell - Handling passwords.

Top articles in this section

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.

PowerShell TCP Listener

PowerShell uses the following commands to open a socket on a specific port via System.NET:

PowerShell: Prevent screen saver, lock: Move mouse regularly

Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver:

Questions / Comments