SharePoint Online: Move Subsite to Another Site using PowerShell

Requirement: Move the Subsite to a new site in SharePoint Online.

How to move a subsite in SharePoint Online?

As a SharePoint Online administrator, you may need to move a subsite from one site to another. In this blog post, we’ll walk through the process of moving a subsite from one SharePoint Online site to another using PowerShell and the web browser interface. This can be helpful if you need to move content or reorganize your site structure. Let’s get started!

Let’s move a subsite to the root site in SharePoint Online using the content and structure page:

  1. Go to the Site Settings page >> Click on the “Content and Structure” link (https://tenant.sharepoint.com/sites/your-site-collection/_layouts/15/sitemanager.aspx)
  2. Select the subsite from the Tree view >> Click on “Move” from the subsite’s context menu.
    sharepoint online move subsite to another site
  3. Select the target site and click “OK” to move the subsite to the new site.
    sharepoint online move subsite to another subsite

This moves the subsite to another site in the same site collection. We can also use this method to move the SharePoint Online subsite to another subsite.

PowerShell to move a subsite to another site in SharePoint Online

Let’s move a subsite to the root site with PowerShell. By using this script, you should be able to successfully move a subsite to another site in SharePoint Online.

#Set Parameter values 
$SiteURL  = "https://crescent.sharepoint.com/sites/marketing/us/2017"
$NewSiteURL = "/sites/marketing/2017"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the Web
$Web = Get-PnPWeb

#Move the site to New URL by Setting relative URL
$Web.ServerRelativeUrl = $NewSiteURL
$Web.Update()
Invoke-PnPQuery

This moves the subsite under https://crescent.sharepoint.com/sites/marketing/us/2017 to https://crescent.sharepoint.com/sites/marketing/2017.

Please note, this method works only within the site collection! If you want to copy or move a subsite to another site collection, You got to use any 3rd party migration tools like ShareGate.

How do I get to content and structure in SharePoint Online?

To access the Site Content and Structure, use this URL: https://YourTenant.sharepoint.com/sites/YourSite/_layouts/15/sitemanager.aspx . Make sure you replace the YourTenant and YourSite in the URL accordingly. This page is available only to site collection administrators.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “SharePoint Online: Move Subsite to Another Site using PowerShell

  • Hi,
    Is it possible to move one subsite from one site collection to another site collection?

    Reply
      • Would it be possible to move a subsite between site collection using MS Graph REST API?

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *