0

We have a live communication modern site, and i want to duplicate this site and all its content into a test site so i can test things before modifying the live. so is this possible inside SharePoint online? or are there any free tools to achieve this?

1

1 Answer 1

1

Probably your best option is using the PnP Provisioning Framework. This framework was initially started as a better approach to templating, intending to replace the classic web templates and site definitions, but has grown into much more.

Although there are numerous options that I won't cover here, a basic script using the Provisioning Framework in PnP-PowerShell would look something like this:

$sourceConn = Connect-PnPOnline -Url https://yoursite.sharepoint.com/sites/site1 -UseWebLogin -ReturnConnection
$destConn = Connect-PnPOnline -Url https://yoursite.sharepoint.com/sites/site2 -UseWebLogin -ReturnConnection

Get-PnPProvisioningTemplate -Out template.pnp -connection $sourceConn

Apply-PnPProvisioningTemplate -Path template.pnp -connection $destConn

4
  • thanks for the usful reply. but will this code affect the source list by any mean? i do not think so, is this correct? so is it safe to perform on a live site?
    – John John
    Feb 21, 2020 at 23:00
  • The 'Get' function will affect nothing but the file you output to. The 'Apply' function, however, if done to an already in-use site could wreak havoc. So be very careful where you apply it.
    – willman
    Feb 21, 2020 at 23:55
  • i tried your appraoch but i got this error Get-PnPProvisioningTemplate : The remote server returned an error: (403) Forbidden. At line:1 char:1 + Get-PnPProvisioningTemplate -Out template.pnp -connection $sourceConn on Get-PnPProvisioningTemplate -Out template.pnp -connection $sourceConn
    – John John
    Feb 25, 2020 at 13:00
  • Sorry, I forgot that the Connect-PnPOnline needs to have the ` -ReturnConnection` if you need to save the connection in a variable, your two $..conn objects were probably both null. I edited the answer to show those parameters. Also, you generally have to be a site collection admin of the sites you are connecting to to use the provisioning cmdlets.
    – willman
    Feb 25, 2020 at 14:49

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