Disabling OneDrive Access and Removing Data for Specific Users via PowerShell

Muhammad Faraz Imran 0 Reputation points
2024-11-02T09:58:12.0833333+00:00

I would like to explore options for deleting specific users' OneDrive data using a PowerShell script. I have around 1500+ active users with OneDrive access, and I want to disable OneDrive access for around 500+ specific users and remove the files from their OneDrive.

Is there a way to disable OneDrive access for these specific users and remove the data from their OneDrive?

I am the Global Administrator of the tenant.

OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,285 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,634 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 108.6K Reputation points MVP
    2024-11-02T15:25:26.97+00:00

    You can use the Remove-SPOSite cmdlet for that, simply provide the URL for the user's OneDrive for Business site collection. Of course, make sure that users have saved any data before going that route.


  2. Jiajing Hua-MFST 11,360 Reputation points Microsoft Vendor
    2024-11-04T06:40:05.8133333+00:00

    Hi @Muhammad Faraz Imran

    When you permanently delete a OneDrive, you will not be able to restore it. Please check following link:

    https://learn.microsoft.com/en-us/sharepoint/restore-deleted-onedrive#permanently-delete-a-onedrive

    https://www.sharepointdiary.com/2017/04/how-to-delete-onedrive-for-business-site-collection-sharepoint-online.html

    (Since the web site is not hosted by Microsoft, the link may changed without notice. )********************************************

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.