2021/04/11 Microsoft Cloud Solutions 1926 visit(s) 5 min to read
Karim A. Zaki
Today’s blog explores two different retention policy scenarios for OneDrive For business. The first one is accomplished from Compliance center search contents and the second is from SharePoint admin center, so with no further ado, let’s dive right in.
The table below shows a comparison between the retention and configuration capabilities of compliance center and SharePoint.
The security and compliance center can be used to retain OneDrive Data, often for compliance reasons, noting that the data will be retrieved using content search. This method helps you accomplish the following:
A user's OneDrive URL is based on their username. For example, https://domain-my.sharepoint.com/personal/user1_domain_com
.
The image below shows how the result looks like after restoring the data.
Go to OneDrive admin portal
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
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
Note
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.
Let’s start with the restore process by installing SharePoint PowerShell. The following is all the commands needed:
#install sherepoint online Module
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
# connect to your sharepoint tenant
Connect-SPOService -Url https://mydomain-admin.sharepoint.com
# get list of deleted users URL
Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url
#restore the user
Restore-SPODeletedSite -Identity https://yourdomain-my.sharepoint.com/deleteduser/deleteduser_yourdomain_com
# assign admin to open
Set-SPOUser -Site https://yourdomain-my.sharepoint.com/deleteduser/deleteduser_yourdomain_com -LoginName admin@yourdomain.com -IsSiteCollectionAdmin $True
# When you permanently delete a OneDrive, you will not be able to restore it.
Remove-SPOSite -Identity https://yourdomain-my.sharepoint.com/deleteduser/deleteduser_yourdomain_com
Remove-SPODeletedSite -Identity https://yourdomain-my.sharepoint.com/deleteduser/deleteduser_yourdomain_com
The following is an explanation of each command
Download SharePoint Online Management Shell from Official Microsoft Download Center
Connect-SPOService -Url Connect-SPOService -Url https://yourdomain-admin.sharepoint.com
Now connect to know if the user’s data is available or not
Get-SPODeletedSite -Identity
A user's OneDrive URL is based on their username.
For example, https://yourdomain-my.sharepoint.com/personal/user1_contoso_com
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
Assign administrator to view the data
Set-SPOUser -Site
After you finish remove then delete
Remove-SPOSite -Identity
Remove-SPODeletedSite -Identity
Restore a deleted OneDrive - OneDrive | Microsoft Docs
Karim A. Zaki
Ctelecoms Team