3

We have numerous sub-sites that are under our top level site collection which we would like to move into their own site collection. Is this something that can be done via PowerShell? If so how? The solutions I have seen so far are for on-premise.

For example the sub-site https://foo.sharepoint.com/bar would become https://foo.sharepoint.com/sites/bar and show as a site collection in SharePoint Admin.

I am not sure what content is in these sub-sites and if they have unique permissions, do these need to be taken into consideration?

1
  • 1
    I would strongly advise getting a migration tool/suite from one of the major ISV players. Commented Dec 1, 2016 at 14:35

1 Answer 1

2

Workaround

There are no OOTB solutions for this since the SharePoint Online cmdlets are very limited, and Export-Import doesn't exist today.

However, you can save your subsite as template /_layouts/15/savetmpl.aspx and include content. When saved download the template from the solution gallery by clicking on the template name _catalogs/solutions/Forms/AllItems.aspx.

Create a new site collection in the SharePoint admin center, and in the custom tab select template later:

enter image description here

When the site collection is created, browse to the new site and hit the solution link. Upload the template and activate it. Go back to your root site url, and select your custom template.

enter image description here

Now you have "moved" your subsite to a site collection of its own, but without PowerShell.

On Premise or using Office Dev PnP PowerShell

First, create a Site Collection on url https://foo.sharepoint.com/sites/bar with the same template as your subsite https://foo.sharepoint.com/bar.

Second, use Export-SPWeb

Export-SPWeb https://foo.sharepoint.com/bar -Path "d:\temp\bar-export.cmp"

Third, use Import-SPWeb

Import-SPWeb https://foo.sharepoint.com/sites/bar -Path "d:\temp\bar-export.cmp" -Force

Now, verify that the imported web is equal to your subsite, before you delete the subsite.

5
  • Make sure to use -IncludeSecurity for your unique perms and optionally -IncludeVersions.
    – Bunzab
    Commented Dec 1, 2016 at 10:11
  • Are these cmdlets available for SharePoint Online?
    – mhep
    Commented Dec 1, 2016 at 10:44
  • @mheptinstall No actually, but you can use Office Dev PnP PowerShell to run Server PowerShell in the cloud: github.com/SharePoint/PnP-PowerShell
    – Benny Skogberg
    Commented Dec 1, 2016 at 11:59
  • @mheptinstall I've updated my answer with a workaround!
    – Benny Skogberg
    Commented Dec 2, 2016 at 8:03
  • 1
    Thanks, tried this yesterday but ran into an error with file names/paths in some of the libraries being too long.
    – mhep
    Commented Dec 2, 2016 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.