logo
search
SharePoint Document Issues

How to Find SharePoint Files Not Modified for Over Two Years

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

Question details

The user needs to identify and export an inventory of files across a SharePoint tenant that have not been modified in more than two years.

Product
Microsoft SharePoint
Device & OS
not provided
Scenario
Auditing a SharePoint environment to locate old, inactive documents for cleanup or archiving purposes.
Observed behavior
Extracting a list of files older than 730 days using administrative search tools or scripted solutions.
Before you start

Ensure you have the required eDiscovery or administrator permissions in Microsoft Purview before attempting a content search, and verify that your PowerShell environment supports modern authentication.

Solution 1Recommended

Use Microsoft Purview Content Search

This is the most straightforward method to locate files across selected SharePoint sites or an entire tenant without writing scripts.

Microsoft Purview allows administrators to run a Content Search using Keyword Query Language (KQL). You can easily filter files by their last modified date and export a comprehensive report.

1
Open Microsoft Purview

Log in to the Microsoft Purview compliance portal using an account with eDiscovery or administrator permissions.

2
Create a New Search

Navigate to the Content Search section and create a new search targeting your selected SharePoint sites or the entire tenant.

3
Apply the KQL Filter

In the query builder, enter a KQL filter to find old files. For example, type lastmodifiedtime<=2022-01-01 (adjust the date to be exactly two years prior to today).

4
Export the Results

Run the search. Once completed, select the option to export the report. The exported CSV will include file names, URLs, modified dates, authors, and sizes.

Free Microsoft Office alternative

Manage Your Daily Documents with WPS Office

While managing complex enterprise environments like SharePoint requires advanced tools like Microsoft Purview and PowerShell, creating and editing everyday documents shouldn't be complicated. WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office for your daily tasks.

  1. 1. Download the Installer: Visit the WPS Office website and download the free version for your operating system.
  2. 2. Install the Software: Run the downloaded file and follow the quick installation prompts.
  3. 3. Start Creating: Open WPS Office to instantly start working with your existing .docx, .xlsx, and .pptx files.
Seamless format compatibility with Microsoft Word, Excel, and PowerPointLightweight installation that runs smoothly on Windows, Mac, and LinuxFree to use for standard document creation, editing, and local managementIntuitive tabbed interface that requires zero learning curve for Office users
microsoft office alternative - wps office

Frequently Asked Questions

Do I need special permissions to use Microsoft Purview Content Search?

Yes, you must be assigned the appropriate eDiscovery Manager or administrator permissions within the Microsoft Purview compliance portal to run content searches and export reports.

What information is included in the Purview exported report?

The exported CSV report from Microsoft Purview typically includes comprehensive file metadata, such as file names, item URLs, last modified dates, author names, and total file sizes.

How do I format the date in my KQL query?

Dates in KQL queries should follow the YYYY-MM-DD format. To find files older than two years, calculate the date 730 days ago and use the filter format: lastmodifiedtime<=YYYY-MM-DD.

Can I use basic authentication for my SharePoint PowerShell scripts?

No, it is highly recommended—and frequently required by modern tenant policies—to use modern authentication when connecting to SharePoint via PowerShell to ensure security and prevent unauthorized access.