How to Delete All Files from Users' OneDrive Accounts
Question details
Administrators need a reliable method to bulk delete all files and folders from multiple users' OneDrive accounts.

- Product
- Microsoft OneDrive, Power Automate
- Device & OS
- not provided
- Scenario
- Managing enterprise cloud storage and clearing user data across multiple accounts.
- Observed behavior
- Standard PowerShell scripts are proving unreliable for deleting all files and folders across multiple accounts, prompting the need for alternatives like Power Automate.
Verify administrative permissions, check for legal holds or retention requirements, and ensure that backups exist or the data is no longer needed before performing bulk deletions.
Use Power Automate to Bulk Delete Files
Create a scheduled cloud flow to reliably iterate through users and delete files in their OneDrive accounts.
Since PowerShell scripts can sometimes run into reliability issues when handling massive bulk deletions across multiple users, a Power Automate flow provides a more robust, structured alternative.
Sign in to Power Automate and create a new Scheduled Cloud Flow to run at your desired time.
Add an action to retrieve the list of targeted users from your Microsoft 365 directory.
Use an 'Apply to each' loop to iterate through the retrieved list of users.
Inside the loop, add an action to list files in the current user's OneDrive folder, and use a nested loop to delete each file. Ensure you add additional actions to process subfolders.

Apply Microsoft Purview Retention Policies
Use Microsoft Purview for long-term governed data lifecycle management rather than immediate deletion.
Manage Your Documents with WPS Office
While managing enterprise OneDrive accounts requires Microsoft 365 admin tools, WPS Office provides a lightweight, free alternative for individual and team document creation. Enjoy a familiar interface and seamless compatibility with all major office formats.
- 1. Visit the Official Website: Go to the official WPS Office website to find the appropriate download for your operating system.
- 2. Download the Installer: Click the 'Free Download' button to get the lightweight installation package.
- 3. Install and Use: Run the installer, set up your free account, and seamlessly open, edit, and save your Microsoft Office formatted documents.

Frequently Asked Questions
Is there an overwrite option when uploading local files to OneDrive?
Yes, when you upload files with the exact same name to the same location, OneDrive typically replaces the existing file with the new one and updates its version history.
Why did my PowerShell script fail to delete all OneDrive files?
PowerShell scripts for bulk operations can sometimes be unreliable due to API throttling, permission errors, timeout issues, or complex subfolder structures. Power Automate often provides a more reliable and structured alternative.
Should I use Microsoft Purview to delete user files immediately?
No, Microsoft Purview retention policies are designed for governed data management and automated lifecycle policies over time. They are not intended for immediate or ad-hoc bulk deletion tasks.




