Skip to main content
Community site session details

Community site session details

Session Id : uWwNRnIvTsjwLHmIstFnnq
Power Automate - General Discussion
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 14 Oct 2022 02:21:03 by

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!

 

  • JennC Profile Picture
    on 16 Oct 2022 at 21:39:24
    Re: Create a flow to delete all of the files in a OneDrive Preservation Hold Library

    @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.

  • grantjenkins Profile Picture
    11,059 Moderator on 14 Oct 2022 at 13:19:43
    Re: Create a flow to delete all of the files in a OneDrive Preservation Hold Library

    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).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete