Invoke-SPOSiteSwap - Swap Or Move Your SharePoint Online Root Site Collection With Another Site

Introduction

 
With the Modern Site on SharePoint Online getting more and more features, the Communications Site provides a platform for creating an organization's intranet. As clean and simple intranet can be created using the default web parts and apps within a Modern Communications Site, an enterprise-scale intranet can be built with integrations and customization using SharePoint Framework solutions.
 
But, in most of the tenants which were created eariler, we always had a classsic site as the root site collection (i.e., https://<your-tenant-name>.sharepoint.com). And the communications sites are always created with an extra path after the root URL (i.e., https://<your-tenant-name>.sharepoint.com/sites/communicationssite). These long URLs are not very effective for creating an organizations intranet. Many customers wanted to have their Communications Site intranet site to be created in their tenant root URL.
 
There were a few workarounds to set a redirect page on your root URL site collection which redirects to the communications site's URL. Though this temporarily solves the issues, users always used to see the long paths in the URL, which is not user-friendly.
Now, we have a provision to swap site collections within the SharePoint online, which allows us to move a communications site to the root URL of the tenant.
 

What is Invoke-SPOSiteSwap

 
This is a new cmdlet added to the SharePoint Online Management Shell which allows a tenant administrator to swap the root site collection or a search center site collection with another site in the tenant.
 

How does this cmdlet work?

 
This cmdlet has the following required parameters.
  • SourceUrl
    This is the URL of any site collection in your tenant which has to be moved

  • TargetUrl
    This should the URL to where the source site will be moved. This URL should the root URL of the tenant or URL of a search center site collection.

  • ArchiveUrl
    This will be a URL where the source site (which is the existing root site collection) will be accessible after the site swap operation is completed
Use the below snippet to swap the root site collection with an existing Communications Site.
  1. $targetSite = "https://<tenant-name>.sharepoint.com"  
  2. $soureSite = "https://<tenant-name>.sharepoint.com/sites/CommunicationsSite"  
  3. $archiveSite = "https://<tenant-name>.sharepoint.com/sites/archivedRoot"  
  4. Connect-SPOService -Url https://<tenant-name>-admin.sharepoint.com  
  5. Invoke-SPOSiteSwap -SourceUrl $soureSite -TargetUrl $targetSite -ArchiveUrl $archiveSite 

Below are the site collections I have before running the cmdlet. A classic site at http://<tenant-name>.sharepoint.com and a communications site at http://<tenant-name>.sharepoint.com/sites/CommunicationsSite
 
 
After the Invoke-SPOSiteSwap cmdlet is executed with the snippet shown above, the communications site us now accessible using the root url of the tenant and the old classic site it moved to /sites/archivedroot URL.
 
 
With this, I now have an intranet site at the root URL of the tenant which is using a Communications Site template.
 

Which version of SharePointOnline Management Shell to use?

 
This cmdlet is available in the SharePoint Admin PowerShell version 16.0.882.1200 or later. You open 'SharePoint Online Management Shell' and use the below snippet to check the version.
  1. $module = Get-Module -Name Microsoft.Online.SharePoint.PowerShell  
  2. $module.Version.ToString() 

 

I have used the latest (at the time of writing this article) version, 16.0.9199.0 for testing this cmdlet. You can download the latest version from here and install it.
 

When will my tenant receive this new command?

 
Below are the details from the Office 365 Notification,
  • Organizations that have approximately 50 licenses or less, will start receiving the update
  • Followed by organizations with approximately 1000 licenses or less
  • For Organizations with more than 1000 licenses, the rollout schedule will be communicated in a future announcement.
The rollout will begin in early August and should be completed by October 2019.
 

Summary

 
My tenant has received the rollout update for Invoke-SPOSiteSwap cmdlet and I could see that this command works very well. We can now use this cmdlet to easily move our Communications Sites to the root URL of the tenant. There is one restriction to cmdlet though. The parameter -TargetURL accpets only a root site collection URL or a search center site collection URL. So, we cannot use this cmdlet to swap any other site collections in the tenant. It can be only the root URL or a search center URL. But it helps in moving our intranet Communications site to the tenant's root URL.