What do if you "lost" your root-site in SharePoint Online

What do if you "lost" your root-site in SharePoint Online

In this article, I am going to explain you the importance of the root-site in SharePoint Online and how to use the PowerShell commands instead of the tempting button in the SharePoint Online Admin-Center.

If you are using SharePoint Online, you surely noticed in your SharePoint Online Admin-Center a Site-Collection under the URL https://[yourtenantname].sharepoint.com. That is the root-site. This root-site can be replaced either with a PowerShell command or a button in the Admin-Center.


Last week, a customer contacted me asking urgently for help. He told me (pretty exhausted) since some hours nobody of their M365-Users or guests was able to access any SharePoint Online Document Library (yep... MS-Teams was also affected) or OneDrive folder. The problem comes in a bad timing since they were changing their Intranet (which meant, they had to replace the root-site... and they did it with the button.

What happens if you delete your SharePoint Online root-site

Actually, you should not be able to delete your SharePoint Online root site. In most cases, this is prohibited via the user interface. However, the customer who called me explained to me they used the "Change home site" button in the SharePoint Online Admin-Center and after that things became bad...

My guess: The root-site has been replaced by the admin more than once within minutes. Maybe he choose the wrong site and immediately re-initiated the process. This resulted in the script behind the button to not work properly.

⚠ If you don't have a root site, you are basically @#$% – all your other SharePoint sites, including everyone’s OneDrive, will stop working until you recover the site from the Recycle Bin or provision a new one (and that was what we had to do to solve the problem... just simply using PowerShell instead of the UI-button in SharePoint Admin-Center.)

How to fix it

In order to fix that, you need to use the following PowerShell Command:


What does this command do?

The SharePoint site collection at the Microsoft 365 tenant root typically occupies the preferred location for a company Intranet. Until some years ago the only way to apply some modern SharePoint functionality was to create a new SharePoint page and make it the Home Page for the site.

Invoke-SPOSiteSwap is a SharePoint Online PowerShell cmdlet that can be used to swap out your old classic SharePoint root site in your Microsoft 365 tenant and replace it with a shiny new Modern Communication Site (preferable), Modern Team Site or Classic team Site.

How to use it

First of all ensure you have the latest SharePoint Online Management Shell installed (Link)

Run PowerShell (as an administrator) and login to SharePoint Online with the following command:

Connect-SPOService -Url https://[yourdomain]-admin.sharepoint.com

once you are connected, run the following command (in one line):

Invoke-SPOSiteSwap -SourceURL https://[yourdomain].sharepoint.com/sites/home -TargetURL https://yourdomain.sharepoint.com -ArchiveUrl https://yourdomain.sharepoint.com/sites/archivedhome

SourceURL — This is the new site that you want to swap with your old tenant classic root. If TargetURL is the tenant root then SourceURL must be an existing Modern Communication site, Modern Team Site or Classic Team Site.

TargetURL — This is your existing Classic root site in the Office 365 tenant (or existing Search Centre, not covered here)

ArchiveURL — location to archive existing root content.

How long does it take?

Typically less than 5 minutes ! No content is actually being moved around so the size of your existing tenant root is not relevant here. Having said that the content is re-crawled after the move to rebuild the search index. That could take some time.

What you should be aware of

  • Source & target sites cannot be associated with an Office 365 Group or Hub site. If a Hub site association exists then remove this first and re-create after the swap process.

  • Featured Links will be lost in the process (displayed on SharePoint Home) so take note of these and re-create as required after the swap completes.

  • Note that currently the Classic Site Collection page will still list the tenant root site even though it’s now using a Communication site template.

  • You may get a 404 error in the browser if you try to access the root site during swap. Give it a few minutes.

Hope this helps. In my case, the customer was pretty relieved ;-).

Did you find this article valuable?

Support Mirco Ingenito by becoming a sponsor. Any amount is appreciated!