22,348 total views, 3 views today
In this SharePoint replace root site article, we will learn about how to replace the root site in SharePoint online from the Microsoft 365 (Office 365) admin center. This option was not available earlier, I would say this is a huge improvement towards a better intranet for the user. With this addition, we can have our own custom branded site, later on, we can convert the branded site to a tenant root site.
For example, for any subscription when we create a tenant for SharePoint Online – the default root site URL would be in the below format:
Format: https://tenantname.sharepoint.com Example: https://globalsharepoint2020.sharepoint.com
For this demo, I have created another communication site as – https://globalsharepoint2020.sharepoint.com/sites/home, we are going to replace the site with a tenant root site – meaning after replacing if the user types the https://globalsharepoint2020.sharepoint.com, the new home site will be opened.
Please see the below screenshot, where we have shown two sites:
- https://globalsharepoint2020.sharepoint.com – tenant current root site
- https://globalsharepoint2020.sharepoint.com/sites/home – future root site

Steps to replace the root site in the SharePoint admin center
Assume that you have a global administrator or SharePoint administrator role for your tenant and have opened the SharePoint admin center URL.
Note:
- Admin Center URL – https://globalsharepoint2020-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/siteManagement/view/ALL%20SITES
Step1: Select your current root site as shown below.
Step 2: Click on the three dots (…) in the menu.
Step 3: Click on the “Replace site” link from the dropdown list.

Step to pass the site URL parameter – URL of the site you want to use
In the next right-side panel we will get the “Replace root site” configuration page where it will be mentioned in the below text:
“Specify a different site to use as the root (top-level) site for your organization. The site you select must be a team site or communication site. It can’t be a hub site or connected to a Microsoft 365 Group.”

Then we need to pass the below parameter:
- URL of the site you want to use, example: https://globalsharepoint2020.sharepoint.com/sites/home
Note:
- We will see the message like the current site will be moved to https://globalsharepoint2020.sharepoint.com/sites/archive-2021-05-25T112415Z
Step to check the site validation
Here the tool will check whether this site can be replaced as a new root site – internally it will check all prerequisites to become a root site, if everything goes well, we will see this message “This site can be used as the root site – site validation” in green color which indicates that the site is ready for the swap.

Click on the “Save” button.
Note
- The current root site will be moved to https://globalsharepoint2020.sharepoint.com/sites/archive-2021-05-25T112415Z
Immediately on the next screen, we will see the status message as “Replacing root site” (as shown below).

Now we could see that no more the old root site is in an active state – now it has been archived (as shown below).

Now onwards if you browse your tenant root site it will be redirected to the new root site.
Now, we will show you a couple of screenshots.
Before swapping the site the new home site was as below:

After swapping the site – refresh the same page, we will be redirected to the tenant root site URL as below:

The old tenant root site has been archived after the swapping as shown below:

How to swap the root site in SharePoint Online using PowerShell?
The swap whatever we have using the Microsoft 365 admin tool (SharePoint Online Administration) user interface, we can do the same swapping of the root site using the below PowerShell script in SharePoint Online:
####The below script is used to swap the old root site to new home root site. cls $PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue if($PSshell -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $fileName = "SwapRootSiteUsingPowerShell" #'yyyyMMddhhmm yyyyMMdd $enddate = (Get-Date).tostring("yyyyMMddhhmmss") $logFileName = $fileName +"_"+ $enddate+"_Log.txt" $invocation = (Get-Variable MyInvocation).Value $directoryPath = Split-Path $invocation.MyCommand.Path $directoryPathForLog=$directoryPath+"\"+"LogFiles" if(!(Test-Path -path $directoryPathForLog)) { New-Item -ItemType directory -Path $directoryPathForLog #Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } $logPath = $directoryPathForLog + "\" + $logFileName $isLogFileCreated = $False function Write-Log([string]$logMsg) { if(!$isLogFileCreated){ Write-Host "Creating Log File..." if(!(Test-Path -path $directoryPath)) { Write-Host "Please Provide Proper Log Path" -ForegroundColor Red } else { $script:isLogFileCreated = $True Write-Host "Log File ($logFileName) Created..." [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } else { [string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg) Add-Content -Path $logPath -Value $logMessage } } #Paramaters area $adminSiteURL="https://globalsharepoint2020-admin.sharepoint.com" $sourceSiteURL="https://globalsharepoint2020.sharepoint.com/sites/Home" $targetURL="https://globalsharepoint2020.sharepoint.com" $archiveURL="https://globalsharepoint2020.sharepoint.com/sites/archive-2021-05-25T112415Z" $userName = "YourSPOUserName" $passWord = "YourSPOPassword" $encPassWord = convertto-securestring -String $passWord -AsPlainText -Force $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord #Paramaters area - Ends try { Connect-SPOService -Url $adminSiteURL #Command Syntax #Invoke-SPOSiteSwap -SourceURl "https://yourdomain.sharepoint.com/sites/home" -TargetURL "https://yourdomain.sharepoint.com" -ArchiveUrl "https://yourdomain.sharepoint.com/sites/archivedhome" #Command example Invoke-SPOSiteSwap -SourceUrl $sourceSiteURL -TargetUrl $targetURL -ArchiveUrl $archiveURL Write-Host "The site has been swapped Successfully" -BackgroundColor Green } catch { $ErrorMessage = $_.Exception.Message +"in swapping the site!:" Write-Host $ErrorMessage -BackgroundColor Red Write-Log $ErrorMessage }
Here the “Invoke-SPOSiteSwap” command does the job, the syntax of the command is as below:
Invoke-SPOSiteSwap -SourceURl "https://yourdomain.sharepoint.com/sites/home" -TargetURL "https://yourdomain.sharepoint.com" -ArchiveUrl "https://yourdomain.sharepoint.com/sites/archivedhome"
Notes:
- The account that is executing the script should be a global administrator.
- The home site must be a modern communication site.
- The SharePoint Online Management Shell must be installed in the machine where you are executing the script – it can be downloaded from here.
General use cases of swapping of root site in SharePoint Online – SharePoint replace root site (Root site swap)
Let’s say you have created a new modern communication site where you did a lot of customization in order to align with your company’s policy or in the existing modern communication site you have done the customization and that site you want to represent as your company’s home site – then we can make use of the swapping functionality.
Summary: What we had here (Replace root site SharePoint)?
Thus, in this article, we have learned the below with respect to swapping the root site in SharePoint Online:
- In 2 steps replace/swap the root site in SharePoint Online using Microsoft 365 and PowerShell.
- How to replace the root site in SharePoint Online from Microsoft 365?
- How to swap the root site in SharePoint Online from Microsoft 365?
- How to swap the root site in SharePoint Online from Microsoft 365?
- How to swap the root site in SharePoint Online using the PowerShell command/script.
- How to use the “Invoke-SPOSiteSwap” command in SharePoint Online?
- Use cases of swapping of root site in SharePoint Online
See Also: SharePoint Online PowerShell
You may also like the following SharePoint PowerShell tutorials:
- [Verified]: Find all InfoPath forms in SharePoint using PowerShell
- [Verified]: Remove recycle bin items in SharePoint using PowerShell
- [Verified]: Cancel SharePoint workflows using PowerShell
- SharePoint Online: Remove custom app using PnP PowerShell
- Office 365: How to create content type in SharePoint Online using PowerShell?
- Office 365: How to create document library in SharePoint Online using PowerShell?
- Export SharePoint user information list to CSV(Excel) file using PowerShell
- How to fix “The term ‘Get-MsolUser’ is not recognized as the name of a cmdlet”
- How to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error
- How to hide quick launch menu in SharePoint online using PnP PowerShell
- Edit user Permission is greyed Out SharePoint Online
- Get workflow inventory from SharePoint online using PowerShell CSOM
- Create a modern team site using PnP PowerShell in SharePoint
- In 2 steps convert a classic SharePoint page to modern using PnP
- SharePoint Online: Delete All Files from document library for the given date – PowerShell CSOM
- Create SharePoint online list using PnP provisioning template
- SharePoint Automation: PowerShell script to get remote server information
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM
- SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM
- SharePoint Online Automation – O365 – Update document library metadata using PowerShell CSOM