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:
[PowerShell] Connect-SPOService -Url https://SHAREPOINT-admin.sharepoint.com -credential YOUREMAIL@domain.com 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> [/PowerShell]
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.