Disable OneDrive Retention Policy for One User Account

Copper Contributor

We have one OneDrive default retention policy for all staff in M365.  We have one user, because of the work they do, has one file that is rewritten many times during the day which creates an incredibly huge version history.  I can't delete the version history because of the retention policy.  I don't need more than a day or two retention.  


It looks like I can create an exclusion by going to Admin portal --> Compliance --> Data Lifecycle Mgmt --> Microsoft 365 --> Retention Polices --> I keep clicking Next till I get to "Choose Where to Apply This Policy"  then I select OneDrive accounts.     


Under Included we have "All user accounts".  Under Excluded we currently have "None".  In order to exclude someone I need "remove all the included ones".  In order to include someone it looks like I have to remove all the excluded ones. 


Clearly I am either misreading this or just not understanding.  I need to exclude this one user or be able to delete the many 100's of versions of this one file.  Your help is appreciated.

5 Replies

@Iamdavidc Best way to do this is via PowerShell. How familiar are you with PS and commands? Here's the script you're going to run to remove the user from the 'All' policy:

Set-RetentionCompliancePolicy -Identity "Policy-Name" -AddOneDriveLocationException "https://tenant-name-my.sharepoint.com/personal/user_domain_com/"

You'll replace Policy-Name with the name of your policy and the url with the user's OneDrive url. If you need detailed PS instructions let me know and I can get the list together. Hope this helps!



Try this:


Set-RetentionCompliancePolicy -Identity "existing-Retention-Policy" -AddOneDriveLocation "https://tenant-name-my.sharepoint.com/personal/user_domain_com/"


@Andrew Geddes  Thank you for the assist.  I am going to give this a try as soon as I am back in the office.  I don't work with PowerShell scripts often but I think I am familiar enough to follow your suggestion.  I will write back either way.  Thanks again.

@Kidd_IpThanks for the recommendation. It looks similar to the previous recommendation and I will give it try when I am back in the office and will post results here. Many thanks.

@Kidd_Ip isn't your script to add to retention policy, not remove? I've used the one I placed above when we had the occasional issue of PST or whatever without issue.