Advertisement

If you are also using SharePoint or OneDrive Online – welcome! It is a great Software as a Service (SaaS) cloud tool from Microsoft and I really love it. Unfortunately I had the following case last time:
A SharePoint site which was linked to an Office 365 group was accidentally deleted and I was not able to restore it via Microsoft 365 (M365) Admin Center, because it happened more than 30 days ago.
In general, all resources of the O365 group are deleted after a period of 30 days. But not the SharePoint site! It will be retained for 93 days – That’s great.
Keep in mind that this can also happen with OneDrive storages of users. After 30 days they are basically gone, but can still be restored with SharePoint Online Management Shell. SharePoint Online Restore Site

At first, you have to establish a connection to SharePoint Online with PowerShell. Let’s check if the module is already installed:

Advertisement
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version

If not, simply install it:

Install-Module -Name Microsoft.Online.SharePoint.PowerShell

Now we can set up the connection. If you have Multi Factor Authentication (MFA) enabled, you cannot pass the credentials with the Get-Credentials command. But you can use this snippet:

$orgName="<Insert your Org name here>" 
Connect-SPOService -Url https://$orgName-admin.sharepoint.com

A window will pop-up prompting you for the MFA code from Microsoft Authenticator or the text message. After authentication is done – we are nearly finished.
Check the Deleted Sites for your site name and store it directly in a variable:

$deletedSite = Get-SPDeletedSite /sites/site_name

At last restore the deleted site:

Restore-SPDeletedSite -Identity $deletedSite

If you want to check out more about the possibilites and the SharePoint PowerShell, I recommend you to check Microsoft Docs.
If you are new to PowerShell, check out my other articles
SharePoint Online Restore Site

Advertisement
Previous articleExport Active Directory Groups and their Members from a specific Organizational Unit as CSV with PowerShell
Next articleGet Inactive Computers In Active Directory From Specific Organizational Unit With PowerShell

LEAVE A REPLY

Please enter your comment!
Please enter your name here