How to Automate Access to Terminated Users' OneDrive Accounts
Question details
An administrator needs a bulk method to grant a manager access to multiple terminated users' OneDrive accounts.

- Product
- Microsoft 365 / OneDrive
- Device & OS
- not provided
- Scenario
- Managing data access for departing or terminated employees efficiently across a specific region without configuring each account one by one.
- Observed behavior
- Manual configuration through the Microsoft 365 and SharePoint admin centers is too time-consuming for multiple accounts, requiring an automated scripting solution.
Ensure you have the SharePoint Administrator role in Microsoft 365 and that the latest version of the SharePoint Online Management Shell is installed on your computer.
Use PowerShell to Automate OneDrive Access Delegation
Utilize the SharePoint Online Management Shell to script and assign site collection administrator rights across multiple OneDrive URLs simultaneously.
While the Microsoft 365 and SharePoint admin centers allow you to assign administrators to individual OneDrive accounts, they lack native bulk-action capabilities for this specific task. PowerShell is the most efficient and officially supported method to iterate through multiple users and delegate access instantly.
Create a CSV file containing the list of OneDrive URLs for the terminated users and the User Principal Name (UPN) of the manager who needs access. Name the columns appropriately, for example, 'OneDriveUrl' and 'ManagerUPN'.
Open PowerShell as an administrator and run the command 'Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com' to authenticate with your Microsoft 365 tenant credentials.
Use a foreach loop to iterate through the CSV file rows and run the 'Set-SPOUser' cmdlet. The specific command structure should be: 'Set-SPOUser -Site $row.OneDriveUrl -LoginName $row.ManagerUPN -IsSiteCollectionAdmin $true' to grant the manager admin rights.

Looking for a cost-effective alternative for your team?
While Microsoft 365 offers robust enterprise administration, managing licenses for transitioning staff can be complex and expensive. WPS Office provides a free, lightweight, and highly compatible alternative for everyday productivity, ensuring a seamless transition with an interface your team already knows.
- 1. Download the software: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install and launch: Run the setup file and follow the brief installation prompts. Once installed, launch the application.
- 3. Open existing files: Directly open your existing DOCX, XLSX, and PPTX files. WPS Office ensures formatting is preserved seamlessly without requiring a Microsoft license.

Frequently Asked Questions
How long does a terminated user's OneDrive data remain accessible?
By default, when a user's Microsoft 365 account is deleted, their OneDrive data is retained for 30 days. Administrators can modify this retention period up to 3650 days (10 years) via the SharePoint admin center before the data is permanently purged.
What permissions does a manager need to view a former employee's OneDrive?
To view, download, or move files, the manager must be designated as a Site Collection Administrator for that specific user's personal OneDrive site.
Will the manager receive an email notification when access is granted via PowerShell?
No, granting Site Collection Administrator rights via the Set-SPOUser cmdlet in PowerShell happens silently. The manager will not receive an automated email, so the administrator must provide them with the direct OneDrive URLs manually.




