Compliance Problems

How to Automatically Delete Inactive OneDrive or SharePoint Folders

Huda QurayshiHuda Qurayshi Oct 10, 2026 868 views

Question details

The user is looking for a way to automatically remove shared folders in Microsoft 365 after a specified period of inactivity.

How to Automatically Delete Inactive OneDrive or SharePoint Folders
Product
Microsoft OneDrive and SharePoint
Device & OS
not provided
Scenario
Managing storage lifecycle and ensuring compliance by cleaning up shared folders that are no longer actively used by the team.
Observed behavior
Folders and their contents remain in OneDrive or SharePoint indefinitely unless manual action is taken or an automated lifecycle policy is enforced.
Before you start

Ensure you have the necessary administrative privileges, such as Compliance Administrator or Global Administrator roles in Microsoft 365, to create and manage retention policies.

Solution 1Recommended

Configure Microsoft Purview Retention Policies

Set up automated rules in Microsoft Purview to delete OneDrive and SharePoint content after a specified inactivity or retention period.

Microsoft 365 utilizes Microsoft Purview retention policies to manage data lifecycles. You can configure these policies to automatically delete items in specific SharePoint sites and OneDrive accounts once they reach a designated age, helping your organization meet compliance and storage rules.

1
Access the Microsoft Purview Compliance Portal

Log in to the Microsoft Purview compliance portal using your administrator credentials.

2
Navigate to Retention Policies

In the left navigation pane, select 'Data lifecycle management', click on 'Microsoft 365', and then select the 'Retention policies' tab.

3
Create a New Policy

Click 'New retention policy', provide a recognizable name and description for the policy, and click 'Next'.

4
Select the Scope

Choose between an 'Adaptive' or 'Static' scope. For a Static scope, toggle the status to 'On' for 'SharePoint sites' and 'OneDrive accounts', and specify the target URLs if you do not want it to apply globally.

5
Set Deletion Conditions

Choose the option 'Only delete items when they reach a certain age'. Specify the time period (e.g., 5 years) and set the condition to trigger based on 'When items were last modified' to accurately reflect inactivity.

6
Review and Submit

Review your configured settings to ensure they align with your organizational rules, then click 'Submit' to apply the policy.

Configure Microsoft Purview Retention Policies
Policy Application Time: It can take up to 7 days for a new retention policy to fully apply and start deleting eligible content across all specified SharePoint and OneDrive locations.
Free Microsoft Office alternative

Try WPS Office for Seamless Document Management

While Microsoft 365 handles backend cloud compliance like folder retention, WPS Office provides a lightweight, free alternative for everyday document creation and editing. Enjoy high compatibility with Microsoft formats and an intuitive interface without the heavy subscription fees.

  1. 1. Download the Software: Visit the official WPS Office website to download and install the free software suite on your device.
  2. 2. Open Existing Documents: Easily open or drag and drop your existing Microsoft Office files into WPS Office with perfect formatting retention.
  3. 3. Edit and Save: Use the familiar tools to edit your documents and save them locally or back them up to WPS Cloud.
Fully compatible with Microsoft Word, Excel, and PowerPoint file formats.Free and lightweight suite available for PC, Mac, and mobile devices.Familiar user interface ensuring zero learning curve for seamless migration.Built-in robust cloud storage for easy file sharing and collaboration.
microsoft office alternative - wps office

Frequently Asked Questions

Can I recover a SharePoint folder deleted by a retention policy?

Yes, items deleted by a retention policy are typically moved to the Preservation Hold library or the first-stage recycle bin. A SharePoint administrator can recover these items within a specific timeframe (usually 93 days) before they are permanently purged.

Does the retention period start from the creation date or last modified date?

Microsoft Purview allows you to choose the trigger. For managing inactive folders, you should base the retention period on the 'last modified' date, ensuring active files are not prematurely deleted.

Are Microsoft Purview retention policies available in all Microsoft 365 plans?

No. Creating automated retention policies requires specific licensing, typically included in Microsoft 365 E3 or E5, or standalone Exchange Online/SharePoint Online Plan 2 licenses.

Will an automatic deletion policy delete the entire folder or just the files inside?

Retention policies in Microsoft 365 primarily target the individual items (files and documents) inside the folders based on their last modified dates. Once a folder is completely empty, it may remain as a hollow structure unless managed by a site lifecycle policy or manually deleted.