Omar El-Anis – 365 Developer

My experiences with SharePoint, Flows, PowerApps, JavaScript and all of the other lovely web technologies out there!

Office 365 OneDrive PowerShell Recovery

Recover a SharePoint or OneDrive site using Powershell

Recover a SharePoint or OneDrive site using Powershell
I’m sure you’ll have come across the scenario of someone being adamant they have take full ownership of a file from a user who has now left the company (and had their accounts removed) only to discover they had the file shared with them from the users OneDrive account and never copied the file – and of course this turns out to be a department critical file which they urgently need! :/

The first irritant here of course being the fact that the file should have been stored in the department’s SharePoint site and not a OneDrive account, seems all of those training sessions, presentations and online guidelines don’t always go through! But we already knew that didn’t we 🙂

You will need the SharePoint Online Management Shell module installed in order to run the following steps (you can import the module into an IDE session if needed).

Un-comment the command you want to run by removing the trailing ## from the line in the below code:

Connect-SPOService -Url -credential
Get-Command -Module Microsoft.Online.SharePoint.Powershell

## Return only SharePoint Sites
## Get-SPODeletedSite

## For all sites including OneDrive accounts use:
## Get-SPODeletedSite -IncludePersonalSite

## for Only One Drive accounts with minimised view use the following
## Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url

## Recover a deleted site using:
## Restore-SPODeletedSite -Identity <url>
## Assign a site collection admin using:
## Set-SPOUser -Site <url> -LoginName <upnofdesiredadmin> -IsSiteCollectionAdmin $True</upnofdesiredadmin></url></url>

0 0 vote
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

Do you have any ideas for creating write-ups? That’s where I always
struggle and I just end up gazing vacant screen for lengthy time.