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

Delete OneDrive version history using Power Automate

Hi All,

 

I have a business requirement as follows:

 

  1. A user account in OneDrive for business is getting full every 2 weeks. It’s basically versions and metadata associated with the file.

  2. Manually deleting the version history has been tough for the affected user.

  3. Found some related blog where .NET console using client-side object mode to achieve it.  
    https://github.com/balassy/OneDriveVersionCleaner

    another Flow solution is using deleting files in the document library after 7 days. https://powerusers.microsoft.com/t5/Using-Flows/Automatically-delete-files-in-Document-Library-after...

  4. Any pointers to delete version history for OneDrive account for all accounts and for a specific account?

    Any advice would be highly appreciated.   

@yashag2255 

5 REPLIES 5
Pstork1
Dual Super User III
Dual Super User III

Are you saying that the user is filling up 1 TB of space every two weeks?  Or is this OneDrive consumer?  If it is OneDrive for business and they are filling up 1 TB of storage then there is a bigger problem here than just cleaning up.  I would start by doing an analysis of what the user is storing in OneDrive that is taking up so much space.  Even considering many versions the files must be huge to consume 1TB.

 

Also, the versions are necessary to support the Files Restore functionality.  So simply removing the versions may cause as many problems as it solves. 1 TB of space should be more than enough for a user.  Find out what they are doing with all that space.  Its not just filled up with Versions.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Pstork1 ..

 

Thanks for your reply. I totally got your point. 

 

  • IT Department has kept OneDrive for Business for all users to 5 GB.
  • Only this user always exceeds 5 GB the limit as he gets a lot of documents from different partners on a daily basis.


Any option to delete versions of files only for the last 6 months for OneDrive For Business workload? 

 

 
 

Pstork1
Dual Super User III
Dual Super User III

First, let me get a clarification.  Is this for OneDrive for Business on-premises or in the cloud?  I understand the specific limitation if its on-premises, but there's no particularly good reason to limit it if its in the cloud. There's no savings benefit.  All it does is lead to problems like this one.

 

Having said that, I'm not aware of any action that will let you delete versions.  If you dig into that person's OneDrive settings you can change the versioning settings on the main documents library to limit the number of versions created.  This would automatically limit the amount of storage consumed by old versions.  However, I repeat that this will invalidate one of the primary safety nets for OneDrive, files restore.  This feature depends on previous versions to operate.  If the previous versions aren't there the Files Restore feature will be useless.  I really don't recommend limiting or deleting previous versions in OneDrive where storage space is FREE just because IT has decided to put artificial limits in place.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Pstork1 , 

 

Thanks for your reply. I did check with the user to understand what exactly the issue is last week. 

 

  1. Is this for OneDrive for Business on-premises or in the cloud?

    It is OneDrive for Business in the cloud.  

  2. The SharePoint Online tenant has been there for the last 3-4 years. 

  3. It is for issue only for one the OneDrive Accounts that are reported by the user. 

  4. Also, I found that in Storage Metrics for OneDrive Account had enough space of around 700 MB of 5 GB set IT Department.  
  5. However, I discovered that the document library has this list that has exceeded the list view threshold as shown. The current number of items in this document library is 461,316 items which are way beyond the 5000 list view threshold.   

    01 Number of Items in this list exceeds the list view threshold, which is 5000 Items'.jpg

  6.  I think there is not the version history issue but more list threshold for the Documents document library for the user.

    What do you recommend for this kind of scenario? Adding an additional index or edit the list view or restructure the Documents document library? Please advise.   
Pstork1
Dual Super User III
Dual Super User III

For that you have two options. 

 

1) move the files into folders.  Each folder will show up as one item in the view until you drill down into the folder.  So that's one way to get the list view below the limit.  Storage isn't the issue, retrieval is.

2) Index one of the columns and then create a default view that sorts and filters on that column.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,067)