Retention Policy Keeps Deleted Files Visible: Root Cause and Fix
🔍 WiseChecker

Retention Policy Keeps Deleted Files Visible: Root Cause and Fix

You deleted files from a SharePoint document library or a OneDrive folder, but they still appear in search results or in the site’s recycle bin. This is not a glitch. It is caused by a retention policy that is actively preserving those files. When a retention policy is applied to a location, it overrides a user’s delete command by keeping a copy of the item in a preservation hold library. This article explains why deleted files remain visible, how to identify which retention policy is responsible, and how to remove the files permanently if the policy is no longer needed.

Key Takeaways: Stop Retention Policies from Keeping Deleted Files Visible

  • Microsoft Purview compliance portal > Data lifecycle management: View and manage all retention policies that apply to SharePoint or OneDrive locations.
  • Preservation hold library in SharePoint: Hidden document library where retained deleted files are stored; visible only to site collection administrators.
  • PowerShell cmdlet Get-RetentionCompliancePolicy: Identify the exact policy name and its scope for a specific site.

ADVERTISEMENT

Why a Retention Policy Keeps Deleted Files Visible

When a user deletes a file from a SharePoint library or OneDrive, the normal behavior is for the file to move to the site’s first-stage recycle bin. After a set period, it moves to the second-stage recycle bin and eventually gets permanently deleted. However, if a retention policy is applied to that site or folder, the system intercepts the delete action. Instead of removing the file, the system copies it into a hidden preservation hold library. This library is not visible in the default site navigation. The file remains there for the duration of the retention period. During that time, the file still appears in search results and in some admin views. Users may see a ghost copy or a link that no longer opens the original file.

The root cause is that the retention policy is configured with a retention action that preserves content even after deletion. The two main retention actions are “Keep if deleted” and “Keep and delete.” The first action keeps the file for the full retention period after deletion. The second action keeps the file for the specified period and then permanently deletes it. Both actions prevent immediate permanent deletion. The file is not lost; it is simply moved to a protected location.

Preservation Hold Library Details

The preservation hold library is a hidden document library named “Preservation Hold Library” in the site collection. Only site collection administrators can access it directly by appending /PreservationHoldLibrary to the site URL. Files stored in this library are not editable by regular users. They are held until the retention period expires or the policy is removed. The library can contain thousands of files, which can slow down site performance and cause confusion about what is actually deleted.

Steps to Identify the Retention Policy Causing the Issue

  1. Open the Microsoft Purview compliance portal
    Go to https://compliance.microsoft.com and sign in with a compliance administrator or global administrator account.
  2. Go to Data lifecycle management
    In the left navigation, select Policies > Data lifecycle management. This page lists all retention policies and retention labels.
  3. Select the Retention policies tab
    Click the Retention policies tab to view all policies that apply to SharePoint and OneDrive locations.
  4. Check the policy scope
    Click on each policy that includes SharePoint sites or OneDrive accounts. In the policy details pane, review the Locations section. Look for the specific site URL where the deleted files remain visible.
  5. Review the retention action
    In the same policy details, check the retention action. If it says “Keep content for a specific period” or “Keep content indefinitely,” that policy is preventing permanent deletion.

Use PowerShell to Find the Exact Policy

  1. Install the Exchange Online PowerShell module
    Open Windows PowerShell as administrator and run Install-Module -Name ExchangeOnlineManagement. Confirm any prompts.
  2. Connect to Exchange Online
    Run Connect-ExchangeOnline and sign in with a compliance administrator account.
  3. Get the retention policy for the site
    Run Get-RetentionCompliancePolicy | Where-Object {$_.Enabled -eq $true} to list all active policies. Look for policies that include the site URL in the SharePointLocation or OneDriveLocation property.
  4. View the policy details
    Run Get-RetentionCompliancePolicy -Identity "Policy Name" | Format-List to see the full configuration, including the retention action and period.

ADVERTISEMENT

How to Remove Deleted Files from the Preservation Hold Library

You have two options: wait for the retention period to expire or modify the retention policy to release the files. Modifying the policy affects all content under that policy, not just the specific files.

Option 1: Wait for the Retention Period to Expire

If you can wait, the files will be automatically deleted from the preservation hold library once the retention period ends. After that, they will move to the recycle bin and be permanently deleted according to the site’s recycle bin settings. This is the safest method if the policy is still needed for compliance.

Option 2: Modify the Retention Policy to Remove the Site

  1. Edit the policy in the Microsoft Purview compliance portal
    Go to Data lifecycle management > Retention policies. Click on the policy name to open it, then click Edit.
  2. Remove the site from the policy scope
    In the Locations step, find the SharePoint sites or OneDrive accounts section. Remove the specific site URL. Click Next and confirm the changes.
  3. Wait for the policy change to propagate
    It can take up to 24 hours for the change to take effect. After that, the files in the preservation hold library will be released and follow normal deletion behavior.
  4. Manually delete the files from the preservation hold library
    After the policy is removed, site collection administrators can go to https://yourtenant.sharepoint.com/sites/yoursite/PreservationHoldLibrary and delete the files manually. This is optional; the system will clean them up eventually.

Option 3: Use a Retention Label Instead of a Policy

If you need to keep the policy for most content but want to release specific files, apply a retention label with a shorter retention period to those files. The label overrides the policy for that item. This requires careful planning and is not a quick fix for large numbers of files.

If Deleted Files Still Appear After the Fix

Deleted Files Still Show in Search Results

Search results may be cached. Wait 24 to 48 hours for the search index to update. You can also request an immediate index refresh by running Request-SPOPortalHealthRun -SiteUrl "https://yourtenant.sharepoint.com/sites/yoursite" in SharePoint Online Management Shell.

Preservation Hold Library Still Contains Files After Policy Removal

The system does not automatically delete files from the preservation hold library when the policy is removed. Site collection administrators must manually delete them. If you cannot see the library, append /PreservationHoldLibrary to the site URL. If the library is empty but files still appear, the retention policy may still be active on a parent site or a hub site.

Retention Policy Cannot Be Edited

Some retention policies are created by default, such as the OneDrive default retention policy. These policies cannot be deleted or modified. In that case, you must wait for the retention period to expire. The default OneDrive retention period for deleted files is 30 days for active users and 93 days for deleted users.

Retention Policy Actions: Keep vs Delete

Item Keep if deleted Keep and delete
Description Preserves the file for the full retention period after deletion Preserves the file for the retention period, then permanently deletes it
File location after deletion Preservation hold library Preservation hold library
Final deletion After retention period ends, file moves to recycle bin and is deleted per site settings After retention period ends, file is permanently deleted without going to recycle bin
User experience Deleted file remains visible in search and admin views Deleted file remains visible until the period ends, then disappears

Retention policies with the “Keep if deleted” action are the most common cause of files remaining visible after deletion. The “Keep and delete” action also preserves files temporarily but removes them automatically at the end of the period.

After removing the policy or waiting for the retention period, the deleted files will no longer appear in search results or site views. To avoid confusion in the future, review all retention policies regularly and ensure they apply only to the necessary locations. You can also use the PowerShell cmdlet Get-RetentionCompliancePolicy to audit policies across your tenant. For files that must be removed immediately, the only reliable method is to modify the policy scope or wait for the default retention period to expire.

ADVERTISEMENT