Automatically delete OD4B files after 5 years

SharePoint Online comes some interesting retention capabilities. For example, the record management functionalities will allow you to declare specific content types as records after a period of time and move these documents to a Record Center.

This is very nice, but you also might need to do the opposite: Delete some content after it’s reached a certain “age” regardless of it’s type. In this case, you could use document deletion policies for SharePoint and One Drive for Business.

To access your Compliance Policy Center,  you can navigate to the Security and Compliance center from you Office 365 Admin Portal.

Security and compliance center

From there, browse to Data management, Retention then click on the Manage document deletion policies for SharePoint an One Drive for Business link.


Once, in the Compliance Policy Center,  browse to the Deletion Policies link and click New Item.


Give your policy a Name, Description and click the New button to add a new rule for this policy

Name and description

Give your rule a Name, specify the action you want the rule to do. In this case I want to delete the content automatically, so I choose Permanently Delete. Specify on winch date you want the rule to apply in this case Last Modified Date, the time period that applies to the rule in this case 5 year and check the Set as default rule to apply the rule automatically to libraries and sites using this policy.

Then click Save.

New Rule

Back on the New Deletion Policy page, click Save


Now let’s assign this policy to the One Driver for Business sites. Browse to Policy Assignment for Templates and click the New Item button.


Click the First choose a template link

First Chose a template

Select the Assign to OneDrive for Business Template radio button, then click Save

Assign to One Drive

Click the Manage Assigned Policies link

Manage Assinged Policies

From the list, select the policy we created earlier and click Save

Select the policy

Back to the New Template Assignment page, click the Save button


There you go, it might take up to 24 for the policy to take place and would have to wait 5 years to actually see it in action, but if you want you can try it with shorter period of time for testing purposes.

I hope this helps,

Leave a Reply