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.

Microsoft 365 and Office | OneDrive | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 119.6K Reputation points MVP Volunteer Moderator
    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 18,065 Reputation points Moderator
    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.