A file’s modified date lives in its LastWriteTime property. Grab the file with Get-Item and read that property:
(Get-Item -Path C:\Reports\budget-2026.xlsx).LastWriteTime
That’s the same value File Explorer shows in the Date modified column. CreationTime and LastAccessTime sit right next to it on the same object.
In this tutorial, I’ll show you how to get the file modified date in PowerShell for one file, a folder and a remote computer. I’ll also cover changing the date, plus a read-only quirk that only hits Windows PowerShell 5.1.
Get the last modified date of a file with Get-Item
Get-Item returns a FileInfo object with three timestamps. I format each one so the output doesn’t depend on the PC’s regional settings:
$file = Get-Item -Path .\Reports\budget-2026.xlsx
'Modified: {0:yyyy-MM-dd HH:mm}' -f $file.LastWriteTime
'Created: {0:yyyy-MM-dd HH:mm}' -f $file.CreationTime
'Accessed: {0:yyyy-MM-dd HH:mm}' -f $file.LastAccessTime
Output:
Modified: 2026-10-15 09:30
Created: 2026-06-01 08:00
Accessed: 2026-10-22 14:00

Modified is the one you usually want. Get-Item throws an error when the file doesn’t exist, so check the path with Test-Path first in scripts that run unattended.
Format the modified date
LastWriteTime is a DateTime, so ToString() and the -f operator accept any custom format string:
$modified = (Get-Item -Path .\Reports\budget-2026.xlsx).LastWriteTime
$modified.ToString('yyyy-MM-dd')
$modified.ToString('MMMM d, yyyy HH:mm')
'{0:yyyyMMdd_HHmm}' -f $modified
Output:
2026-10-15
October 15, 2026 09:30
20261015_0930
The last pattern is handy for file names. Without a format, PowerShell prints the date in the PC’s regional style, which differs between machines. More patterns are in formatting dates in PowerShell.
Get the modified date of all files in a folder
Get-ChildItem returns the same FileInfo objects for every file. Sort them by LastWriteTime to see the newest first:
Get-ChildItem -Path .\Reports -File |
Sort-Object -Property LastWriteTime -Descending |
ForEach-Object { '{0:yyyy-MM-dd HH:mm} {1}' -f $_.LastWriteTime, $_.Name }
Output:
2026-10-21 08:05 sales-austin.csv
2026-10-15 09:30 budget-2026.xlsx
2026-09-30 17:45 q3-review.docx
2026-07-02 11:20 notes.txt

Add -Recurse to include subfolders and -Filter *.xlsx to limit the file type. The Get-ChildItem guide covers those switches, and sorting files by date goes deeper on ordering.
Get a folder’s last modified date
Folders have a LastWriteTime too, and Get-ChildItem -Directory lists it the same way. It doesn’t mean what most people expect, though:
'Folder date: {0:yyyy-MM-dd}' -f (Get-Item -Path .\Reports\Archive).LastWriteTime
Add-Content -Path .\Reports\Archive\jan.csv -Value 'edited'
'After editing a file: {0:yyyy-MM-dd}' -f (Get-Item -Path .\Reports\Archive).LastWriteTime
New-Item -Path .\Reports\Archive\feb.csv -ItemType File | Out-Null
'After adding a file: {0:yyyy-MM-dd}' -f (Get-Item -Path .\Reports\Archive).LastWriteTime
Output:
Folder date: 2026-08-01
After editing a file: 2026-08-01
After adding a file: 2026-10-23
Editing jan.csv left the folder date alone. Adding feb.csv changed it to today. A folder’s date tracks added, removed or renamed entries, not edits to the files inside.
To find the latest change anywhere in a folder tree, sort its files with -Recurse and take the first one. Getting a folder’s size uses the same recursive pattern.
Get the modified date with [System.IO.File]::GetLastWriteTime
The .NET File class reads the date from a path string without creating a PowerShell object first. Directory has the same method for folders:
$path = Join-Path -Path $PWD -ChildPath 'Reports\budget-2026.xlsx'
[System.IO.File]::GetLastWriteTime($path).ToString('yyyy-MM-dd HH:mm')
$folder = Join-Path -Path $PWD -ChildPath 'Reports\Archive'
[System.IO.Directory]::GetLastWriteTime($folder).ToString('yyyy-MM-dd HH:mm')
$missing = Join-Path -Path $PWD -ChildPath 'Reports\missing.txt'
[System.IO.File]::GetLastWriteTimeUtc($missing).ToString('yyyy-MM-dd HH:mm')
Output:
2026-10-15 09:30
2026-08-01 12:00
1601-01-01 00:00
Pass a full path. .NET resolves relative paths against the process’s working folder, which isn’t always your current PowerShell location.
The last line is a trap: a missing file doesn’t throw, it returns January 1, 1601. Check for that year, or call Test-Path first. GetLastWriteTimeUtc returns UTC, which helps when comparing times across time zones.
Filter files by a modified date range
Compare LastWriteTime inside Where-Object. Use -lt with the day after the end date, so files changed late on October 15 still count:
$from = [datetime]'2026-09-01'
$to = [datetime]'2026-10-15'
Get-ChildItem -Path .\Reports -File |
Where-Object { $_.LastWriteTime -ge $from -and $_.LastWriteTime -lt $to.AddDays(1) } |
Sort-Object -Property Name | Select-Object -ExpandProperty Name
Output: