Forum Discussion
Anonymous
Oct 16, 2018Migrate SPO site to another Tenant /SPO
Hi Are there a PowerShell script available somewhere that move/copy a SPO site from one tenant to another ? or do I have to go with the 'Save as template' or 'map network drive' (Source tenant ...
GambhirA
Nov 12, 2020Copper Contributor
Hi, I have used mover and it is a nice tool if we want to migrate data with spo site. However if we want to replicate a site only with no data and to create a site duplicate from one tenant to other tenant, is there an conventional way to replicate to another tenant ?
Abdullah3077
Dec 13, 2021Copper Contributor
If you just want to replicate the site without data below method can be used.
Using below script create schema/template file of site.
#Set variables
$SiteURL = "https://domain.sharepoint.com/sites/Test"
#Connect to PnP Online
Connect-PnPOnline -Url $siteUrl -Interactive -ForceAuthentication
#Get Site Schema
Get-PnPSiteTemplate -Out "C:\Users\username\Desktop\Data\SiteSchema.xml"
Then invoke or apply template on required site using below script.
#Set variables
$SiteURL = "https://domain.sharepoint.com/sites/Test1"
$SchmaXMLPath = "C:\Users\username\Desktop\Data\SiteSchema.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive -ForceAuthentication
#Apply Pnp Provisioning Template
Invoke-PnPSiteTemplate -Path $SchmaXMLPath -ResourceFolder "C:\Users\username\Desktop\Data\"
Note: In GUI while creating site, the template is selected to be applied. However In this method first site is created using template same as that of old site(If old site is communication site then destination site also should be communication site) and then using above PowerShell script it is directly applied which make the site a replica with same structure as of the old one with pages but no data in other lists and libraries.
Using below script create schema/template file of site.
#Set variables
$SiteURL = "https://domain.sharepoint.com/sites/Test"
#Connect to PnP Online
Connect-PnPOnline -Url $siteUrl -Interactive -ForceAuthentication
#Get Site Schema
Get-PnPSiteTemplate -Out "C:\Users\username\Desktop\Data\SiteSchema.xml"
Then invoke or apply template on required site using below script.
#Set variables
$SiteURL = "https://domain.sharepoint.com/sites/Test1"
$SchmaXMLPath = "C:\Users\username\Desktop\Data\SiteSchema.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive -ForceAuthentication
#Apply Pnp Provisioning Template
Invoke-PnPSiteTemplate -Path $SchmaXMLPath -ResourceFolder "C:\Users\username\Desktop\Data\"
Note: In GUI while creating site, the template is selected to be applied. However In this method first site is created using template same as that of old site(If old site is communication site then destination site also should be communication site) and then using above PowerShell script it is directly applied which make the site a replica with same structure as of the old one with pages but no data in other lists and libraries.