Change a file's modified date in PowerShell

Timestamps are writable properties — set LastWriteTime or CreationTime on (Get-Item file) directly.

WindowsmetadataFilespowershellMedium risk
Run (Get-Item <file>).LastWriteTime = '2026-03-15 14:30:00' to set the modified date; same for .CreationTime.

01Command

Command
$ (Get-Item 'C:\Photos\IMG_0001.jpg').LastWriteTime = '2026-03-15 14:30:00'

02What it does

Because FileSystemInfo exposes settable DateTime properties, no special cmdlet is needed — assignment is the whole trick. It works through pipelines too: Get-ChildItem *.log | ForEach-Object { $_.LastWriteTime = Get-Date } refreshes many files at once. Note this changes filesystem metadata only; EXIF dates inside photos are separate data.

03Risk

RiskMedium risk
RequirementsPowerShell
!Warning: Forging timestamps defeats forensic timelines and can confuse backup tools that rely on incremental dates — use it deliberately, not casually.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-Item | Microsoft Learn
    SS64 · technical · 2026-09-17
    Evidence: SS64 shows assigning .LastWriteTime / .CreationTime on (Get-Item file) and a SetFileTime pattern for bulk timestamp changes.
  • FileSystemInfo.LastWriteTime Property | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents that FileSystemInfo.LastWriteTime is get/set and accepts a DateTime, allowing timestamp modification.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions