Best Practice for restoring OneDrive for business Deleted users

In the following examples we will give a brief about the retention policy scenarios for OneDrive For business.

2 methods

Compliance center search contents and SharePoint admin center


From compliance center

From SharePoint


After and before

After user deleted


Content search



Just the contents

Full path and structure of data and folders


The first method

Create and configure retention policies to automatically retain or delete content – Microsoft 365 Compliance | Microsoft Docs

The security and compliance center to retain OneDrive Data, this method is used for retaining data for compliance reasons also the data will be retrieved using content search.

  • Comply proactively with industry regulations and internal policies 
  • Reduce your risk in the event of litigation or a security breach
  • Help your organization to share knowledge effectively.






data will be retrieved using the search content in the compliance center.

The second Method which is recommended

The result shall look like that after finish go to the URL of the user.

A user’s OneDrive URL is based on their username. For example,

Set the OneDrive retention for deleted users

Go to OneDrive admin portal

OneDrive for Business Admin Preview


Enter the number of days you want to keep the OneDrive files in the Days to retain files in OneDrive after a user account is marked for deletion box.

The minimum value is 30 days and the maximum value is 3650 days (10 years).

This is the process of deletion

OneDrive retention and deletion – OneDrive | Microsoft Docs

When the account is deleted

The account deletion is synced to sharepoint and the OneDrive Cleanup job runs OneDrive Marked for deletion the user will appear in the deleted users for 30 days


Retention policies always take precedence to the standard OneDrive deletion process, so content included in a policy could be deleted before 30 days or retained for longer than the OneDrive retention.

Restore the Data.

Let’s start with the restore process installing the sharepoint PowerShell

The following is all the commands needed

#install sherepoint online Module


# connect to your sharepoint tenant


# get list of deleted users URL


#restore the user


# assign admin to open



# When you permanently delete a OneDrive, you will not be able to restore it.




The following is explanation of each command

Download SharePoint Online Management Shell from Official Microsoft Download Center

Connect-SPOService -Url
Connect-SPOService -Url

Now connect to know if the user’s data is available or not

Get-SPODeletedSite -Identity <URL>

A user’s OneDrive URL is based on their username.

For example,

Lets say you don’t know his URL then run the following command to get all deleted users

If his username appears then it can be restored

Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url

Then restore onedrive to active state

Restore-SPODeletedSite -Identity <URL>

Assign administrator to view the data

Set-SPOUser -Site <URL> -LoginName <UPNofDesiredAdmin> -IsSiteCollectionAdmin $True

After you finish remove then delete

Remove-SPOSite -Identity <URL>

Remove-SPODeletedSite -Identity <URL>


Restore a deleted OneDrive – OneDrive | Microsoft Docs




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.