Jan 04 2023 11:20 AM
Hello everyone,
I need to replicate a site from one tenant to another. For that, I'm following the steps in C-Sharp Corner, which consists in two simple code snippets:
Export site template from original tenant
#Parameters
$SourceSiteURL = "https://qhdm.sharepoint.com/sites/MyTeamsites"
$XMLTemplatePath = "C:\Site Templates\DemoSiteTemplate.xml"
#Connect to source SharePoint
Connect-PnPOnline -Url $SourceSiteURL -Interactive
#Export site template to specified path
Get-PnPSiteTemplate -Out ($XMLTemplatePath)
#Disconnect source SharePoint
Disconnect-PnPOnline
Import site template to destination tenant
#Parameters
$DestinationSiteURL = "https://qhdm.sharepoint.com/sites/DestinationDemoSites"
$XMLTemplatePath = "C:\Site Templates\DemoSiteTemplate.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $DestinationSiteURL -Interactive
#Apply SharePoint template
Invoke-PnPSiteTemplate -Path $XMLTemplatePath -ClearNavigation
#Disconnect source SharePoint
Disconnect-PnPOnline
Exporting the template works great; however, when trying to apply the template in the destination site, the following error appears:
Invoke-PnPSiteTemplate : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
+ Invoke-PnPSiteTemplate -Path $XMLTemplatePath -ClearNavigation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-PnPSiteTemplate], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Provisioning.Site.InvokeSiteTemplate
I have admin permissions on both tenants already. What could possibly be causing this error?
Feb 27 2023 02:37 PM
SolutionFeb 28 2023 06:04 AM