Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

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

(0) ShareShare
ReportReport
Posted on 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
    JennC on at
    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
    grantjenkins 11,057 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard