When a Microsoft 365 retention policy or retention label is applied to a user’s OneDrive, files that match the policy criteria are marked as retained. These files cannot be permanently deleted by the user until the retention period expires or the policy is removed. Locating these files manually across hundreds of folders is time-consuming. This article explains how to identify files affected by retention in OneDrive for Business using built-in search filters, the Microsoft 365 compliance portal, and PowerShell. You will learn the exact steps to find retained files and confirm their retention status.
Key Takeaways: Locating Retained Files in OneDrive
- OneDrive web app > Search > Retention label filter: Filter files by a specific retention label name to see all retained items in that user’s OneDrive.
- Microsoft 365 compliance portal > Content search > OneDrive location: Run a content search targeting OneDrive sites and filter by retention label or policy to export a list of affected files.
- SharePoint Online Management Shell > Get-PnPFolder: Use PowerShell to enumerate all files in a user’s OneDrive and check the RetentionLabel property to confirm retention status.
Why OneDrive Files Become Subject to Retention Policies
Microsoft 365 retention policies and retention labels are designed to protect organizational data from accidental or malicious deletion. When a policy is published to OneDrive accounts, files that match the policy scope—such as documents containing specific keywords or located in certain folders—become subject to retention. These files are assigned a retention label, either automatically by the policy or manually by the user or administrator. Once a file is retained, it cannot be permanently deleted from the OneDrive recycle bin or the second-stage recycle bin until the retention period ends. The file remains visible to the user, but any delete action only moves it to a hidden preservation hold library. The user sees a warning that the file is retained when attempting to delete it. Understanding the difference between a retention policy applied at the tenant level and a retention label applied to individual items is essential for locating affected files correctly.
Retention Policy vs Retention Label
A retention policy is assigned to a location (such as all OneDrive accounts) and applies automatically to all content in that location. A retention label is applied manually to a specific file or folder, or automatically based on a sensitivity label or trainable classifier. Both methods mark files as retained, but the label name appears in file metadata. When searching for retained files, you can filter by the label name if a label was applied. For policy-only retention, the file does not display a label name in the OneDrive UI, but it still cannot be deleted. In that case, you must use the compliance portal or PowerShell to identify the files.
Steps to Find Retained Files in OneDrive for Business
Use one of these three methods depending on your role and the number of files you need to inspect.
Method 1: Use the OneDrive Web App Search with Retention Label Filter
This method works when a retention label has been applied to files. It does not work for files retained by a policy without a label.
- Open OneDrive in a web browser
Sign in to https://onedrive.live.com with your work or school account. - Click the Search box
It is located at the top of the page. - Type the retention label name
Type the exact name of the retention label assigned to the files, for example “HR-Retention-7Years”. - Press Enter
OneDrive displays all files that have that label applied. - Refine results with file type filters
Click the filter icon in the search bar and select Document, Spreadsheet, or other types to narrow the list.
Method 2: Run a Content Search in the Microsoft 365 Compliance Portal
This method works for both labeled and policy-retained files. It requires the Compliance Administrator or eDiscovery Manager role.
- Go to the Microsoft 365 compliance portal
Navigate to https://compliance.microsoft.com and sign in. - Open Content search
In the left navigation, expand Data classification and select Content search. - Create a new search
Click New search and give it a name such as “OneDrive Retained Files”. - Set the location to OneDrive
Under Locations, select Specific sites and choose the OneDrive URL of the user whose files you want to search. You can find the URL in the Microsoft 365 admin center under Active users > OneDrive tab. - Add a retention label filter
If you know the label name, add a keyword query such asComplianceTag:"HR-Retention-7Years". For policy-retained files without a label, leave the query empty to return all files in that OneDrive. - Run the search
Click Search. After the search completes, review the number of items found. - Export the results
Click Export results to download a CSV file containing the file paths, sizes, and retention status of each item.
Method 3: Use PowerShell to Check Retention Properties
This method is best for administrators who need to audit multiple OneDrive accounts. It requires the SharePoint Online Management Shell.
- Install the SharePoint Online Management Shell
Open PowerShell as an administrator and runInstall-Module -Name Microsoft.Online.SharePoint.PowerShell. - Connect to SharePoint Online
RunConnect-SPOService -Url https://contoso-admin.sharepoint.comand sign in with your admin credentials. - Get the OneDrive site URL
RunGet-SPOSite -IncludePersonalSite $trueand note the URL for the user’s OneDrive, for examplehttps://contoso-my.sharepoint.com/personal/user_domain_com. - Connect to the site using PnP PowerShell
RunConnect-PnPOnline -Url https://contoso-my.sharepoint.com/personal/user_domain_com -Interactive. - Retrieve all files with retention labels
Run the following script:Get-PnPFolderItem -FolderSiteRelativePath "Documents" -ItemType File | Select-Object Name, ServerRelativeUrl, @{Name="RetentionLabel";Expression={Get-PnPProperty -ClientObject $_ -Property RetentionLabel}} - Check the output
Files with a retention label display the label name in the RetentionLabel column. Files without a label but still subject to policy retention show a blank value. You can cross-reference these files with the content search export to confirm their retention state.
If Retained Files Are Still Hard to Find
Retention label does not appear in search results
If you type the label name in the OneDrive search box and no files appear, the label may not be indexed yet. Wait up to 24 hours after the label is applied for search to update. Alternatively, the label may have been applied to a folder rather than individual files. In that case, open the folder in OneDrive and check the Retention label column in the file list view.
Content search returns zero results
Ensure the OneDrive site URL you entered is correct. You can verify the URL by going to the Microsoft 365 admin center, selecting Active users, clicking the user, and choosing the OneDrive tab. If the user has never opened OneDrive, the site may not exist yet. Ask the user to sign in to OneDrive at least once to provision the site.
PowerShell script returns no RetentionLabel property
The RetentionLabel property is only available for files that have a retention label applied directly. Files retained solely by a tenant-wide policy do not expose this property. Use the content search method to identify those files instead.
OneDrive Web App Filter vs Compliance Portal Search vs PowerShell: Key Differences
| Item | OneDrive Web App Filter | Compliance Portal Content Search | PowerShell (PnP) |
|---|---|---|---|
| Requires admin role | No | Yes | Yes |
| Works with policy-only retention | No | Yes | No |
| Supports export to CSV | No | Yes | Yes (with additional scripting) |
| Shows retention label name | Yes | Yes | Yes |
| Scans multiple OneDrive accounts | No | Yes | Yes |
Use the OneDrive web app search for quick checks on a single user when you know the retention label name. Use the compliance portal content search for thorough audits across multiple users or for policy-retained files. Use PowerShell when you need to automate the process or integrate with other reporting tools.