Nov 18 2022 04:02 AM
Please can some one advise on the best way to apply a custom design template from one sharepoint to another , so that the copy has the same lists, interface and security. I am trying to create a site ('MyNewsite') & apply a design to it ('My Source Site'), and have hit a number of problems
I have the SharePoint Administrator role enabled
I have looked at the UI , CSOM & PNP.Powershell
SharePoint online native UI behaves as follows
A number of discussions mention clicking on an option in the UI called 'Apply A Site Template', behind the cog icon. I cannot see this option.
CSOM code
var Designs = tenant.GetSiteDesigns();
ctx.Load(existingDesigns);
ctx.ExecuteQuery();
var desiredDesign = Designs.FirstOrDefault(d => d.Title == "My Source Site");
var results = tenant.ApplySiteDesign("MyTenant.sharepoint.com/sites/MyNewsite", desiredDesign.Id);
ctx.Load(results);
.ctx.ExecuteQueryRetry();
This code runs, but does not apply the design to MyTenant.sharepoint.com/sites/MyNewsite
PNP.Powershell V1.12.0
$webUrl="MyTenant.sharepoint.com/sites/MyNewsite"
Connect-PnPOnline -Url $webUrl -Interactive -ForceAuthentication -verbose
Invoke-PnPSiteTemplate -Path C:\myFolder\PnPtemplate.xml -Parameters @{"SiteUrl"=$webUrl}
This code runs, and echos all sorts of changes to the screen , but again when I open MyTenant.sharepoint.com/sites/MyNewsite, it shows the old design.
Please advise on a working method to do this, many thanks in advance.
Best regards, Richard
Nov 20 2022 06:08 AM - edited Nov 20 2022 06:09 AM
Script 1:
Connect-PnPOnline -Url $OldSiteURL -Interactive
Get-PnPSiteTemplate -Out template.xml
Script 2:
#Config Variables
$TemplateXML ="template.xml"
#Connect to PnP Online
Connect-PnPOnline -Url $NewSiteURL -Interactive
#Apply provisioning Template
Invoke-PnPSiteTemplate -path $TemplateXML
Nov 21 2022 12:46 AM
@NicolasKheirallah Many thanks for the reply. The GetPnPSiteTemplate & the InvokePnPSiteTemplate is one of the combinations I tried. The Invoke appears to run through without any errors echoed back. Its just that after the event, nothing changes in the target site.
Do you know what might cause that behaviour?
Thanks again
Nov 21 2022 02:22 AM
Nov 21 2022 02:47 AM
Nov 21 2022 02:57 AM
Nov 21 2022 03:04 AM
Nov 21 2022 03:35 AM