How to Get File Modified Date using PowerShell: 5 Easy Methods

Today, I will address the topic directly. In this tutorial, I will explain how to get the file modified date using PowerShell. There are various methods to do so. Let me explain each method with examples.

Method 1 – Using the Get-Item Cmdlet

The simplest way to get a file’s modified date is using the Get-Item cmdlet in PowerShell. This is my go-to approach for quick checks on individual files.

Get-Item "C:\Reports\Quarterly\Q1_Report.xlsx" | Select-Object LastWriteTime

If you want to see all the time-related properties, you can use:

Get-Item "C:\Reports\QuarterlySales.xlsx" | Select-Object CreationTime, LastAccessTime, LastWriteTime

The LastWriteTime property gives you the last modified date and time of the file. This approach is straightforward and perfect for quick checks on a single file.

You can see the exact output in the screenshot below:

How to Get File Modified Date using PowerShell

Check out Get SharePoint List Name using PowerShell

Method 2 – Using Get-ChildItem for Multiple Files

When I need to check modification dates for multiple files in a directory, Get-ChildItem (alias dir or ls) is much more efficient.

Get-ChildItem "C:\Reports\Quarterly\*.xlsx" | Select-Object Name, LastWriteTime

This will display a list of all Excel files in the Quarterly folder along with their last modified dates.

For a more refined output, you can format the date to your preference:

Get-ChildItem "C:\Reports\Quarterly\*.xlsx" | Select-Object Name, @{Name="Modified Date"; Expression={$_.LastWriteTime.ToString("MM/dd/yyyy hh:mm tt")}}

This formatted output is particularly useful when generating reports for non-technical team members who prefer standardized date formats.

Check out How to Connect to SharePoint Online Using PowerShell

Method 3 – Filter Files by Date Range

Sometimes you need to find files modified within a specific timeframe. Here’s how I approach this common requirement:

$startDate = (Get-Date).AddDays(-7)
$endDate = Get-Date

Get-ChildItem "C:\Reports\" -Recurse | 
    Where-Object {$_.LastWriteTime -ge $startDate -and $_.LastWriteTime -le $endDate} |
    Select-Object FullName, LastWriteTime

This script will find all files in the Reports folder (including subfolders) that were modified in the last week.

You can also see the exact output in the screenshot below:

Get File Modified Date using PowerShell

For quarterly audits, I often use this variant:

$startDate = Get-Date "04/01/2025"
$endDate = Get-Date "05/26/2025"

Get-ChildItem "C:\Reports" -Recurse -File |
    Where-Object {$_.LastWriteTime -ge $startDate -and $_.LastWriteTime -le $endDate} |
    Select-Object FullName, LastWriteTime |
    Export-Csv -Path "C:\Reports\Q2_Modified_Files.csv" -NoTypeInformation

This exports a CSV report of all files modified during the current quarter through today, which is perfect for compliance documentation.

Check out Get All SharePoint Site Collections Using PowerShell

Method 4 – Using the System.IO.File Class

While the cmdlets are convenient, sometimes I prefer using the .NET Framework directly for better performance with large file sets:

$filePath = "C:\Reports\Annual\2025_Q1_Summary.pptx"
$lastModified = [System.IO.File]::GetLastWriteTime($filePath)
Write-Output "Last modified: $lastModified"

For UTC time (useful when working across time zones):

$filePathUtc = "C:\Reports\Annual\2025_Q1_Summary.pptx"
$lastModifiedUtc = [System.IO.File]::GetLastWriteTimeUtc($filePathUtc)
Write-Output "Last modified (UTC): $lastModifiedUtc"

This method is particularly efficient when processing thousands of files, as it has less overhead than the PowerShell cmdlets.

Check out Get Site Template in SharePoint Using PowerShell

Method 5 – Remote File Modified Dates

When managing a distributed infrastructure, I often need to check file dates on remote servers:

$server = "FileServer01"
$remotePath = "D$\Shared\Marketing\Campaigns"

Invoke-Command -ComputerName $server -ScriptBlock {
    Get-ChildItem $using:remotePath | 
    Sort-Object LastWriteTime -Descending | 
    Select-Object Name, LastWriteTime -First 10
}

This script connects to FileServer01 and retrieves the 10 most recently modified files in the Marketing Campaigns folder.

For scheduled monitoring across multiple servers, I use this approach:

$servers = @("FileServer01", "FileServer02", "FileServer03")
$path = "E$\Backups"

foreach ($server in $servers) {
    Write-Output "`nChecking backup files on $server..."
    Invoke-Command -ComputerName $server -ScriptBlock {
        Get-ChildItem $using:path -Filter "*.bak" |
        Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-1)} |
        Select-Object Name, LastWriteTime, @{Name="Server"; Expression={$env:COMPUTERNAME}}
    }
}

This helps identify backup files that haven’t been updated across multiple servers in the last 24 hours, which is crucial for disaster recovery planning.

Check out Get SharePoint Site Members Using PowerShell

Change File Modified Dates using PowerShell

Sometimes, especially when migrating content between systems, I need to preserve or modify file dates:

$file = "C:\Projects\Documentation\Requirements.docx"
$newDate = Get-Date "05/15/2025 09:30 AM"

(Get-Item $file).LastWriteTime = $newDate

This updates the last modified timestamp of the Requirements document to May 15, 2025, at 9:30 AM.

PowerShell offers multiple ways to retrieve and work with file modification dates. I hope this tutorial helps you learn how to get the file modified date using PowerShell using various methods.

I hope you found this article helpful. If you have any questions or additional techniques for working with file dates in PowerShell, please share them in the comments below!

You may also like the following tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…