cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JennC
Helper I
Helper I

Create a flow to delete all of the files in a OneDrive Preservation Hold Library

We had a Retention Policy for OneDrive that led to the creation of Preservation Hold Libraries for each OneDrive account. We have now deleted the Retention Policy but the Preservation Hold Libraries are still there (and the documents are taking up storage space).

 

I'm new to Power Automate and I'm trying to figure out how to build a flow that will delete the files in a Preservation Hold Library of a OneDrive account (as suggested below in advice found online). A screenshot of how to approach this would be a big help!

 

JennC_0-1665713595594.png

 

Before this I tried using the SharePoint action Get files (properties only) and apply to each Delete file but this only worked for a Document Library in a SharePoint site. When I tried it for the Preservation Hold Library in a OneDrive account it timed out after about 4 minutes after getting stuck at apply to each Delete file.

 

Thanks!

 

2 REPLIES 2
grantjenkins
Community Champion
Community Champion

My understanding is that if you had items in the Preservation Hold Library as per the retention policy applied, then you removed the retention policy, the files would start to be deleted automatically as per the recycle bin stages/times.

 

I would confirm this and decide if it's worth creating a flow to delete the items or just wait for the process to resolve itself. I would expect all the files in there to be completely deleted (from both recycle bins) after 93 days after the retention policy has been removed. I'm not sure how long ago you removed the retention policies?

 

If you wanted to delete the items in the Preservation Hold Library you'd need to ensure all of the relevant items have been actioned for the library. Retention policies removed, eDiscovery cases closed, and Data loss prevention policies disabled.

 

If you did want to go ahead with a flow to delete the items:

  • Does the account that's running the flow have permissions to delete the items in the OneDrive account?
  • How long ago did you turn off the retention policies? If only a few hours before you tried the flow it might just need more time to replicate and release the hold.
  • How many items are in the Preservation Hold Library?
  • If you were able to use PowerShell that might make it a bit easier (maybe).


----------------------------------------------------------------------

If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.

@grantjenkins thanks for the reply.

 

The Retention Policy for OneDrive was removed 30 days prior and I have manually removed the items from my one PH library for my OneDrive account so they're no longer on hold.

 

The account running the flow has the required permissions to access OneDrive accounts for other staff members.

 

There is a large number of items in the PH libraries because it also includes the previous revisions. From experience deleting all of my own items, it took a number of bulk deletion attempts because you can only delete something like 200 items at a time (from memory).

 

PowerShell is an option but I don't have a sample script.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,382)