Duplicate SharePoint Site
How to duplicate a SharePoint Site with a SPFx app inside? There are two ways to do it. One is to use the hidden "Save as Template" feature, another is to use PnP PowerShell.
Use “Save as Template”
- Follow the first answer here to enable
denyaddandcustomizepages
using PowerShell.
$adminUPN="winter.wang@antdevstudiosdev002.onmicrosoft.com"
$orgName="antdevstudiosdev002"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
- Follow this blog post to remove your SharePoint SPFx app temporarily if you have one.
- Open “Save as Template” page for your site, format like this: https://your-sharepoint-site-url/_layouts/15/savetmpl.aspx.
- Request access if you have the error “Sorry, you don't have access”, and approve the access using the global admin account from “Access Requests” settings page: https://your-sharepoint-site-url/Access Requests/pendingreq.aspx, or just use the global admin account.
- The template is available at the solution gallery after generated: https://your-sharepoint-site-url/_catalogs/solutions/Forms/AllItems.aspx.
- Now with this template you can follow this guide to set up a duplicate subsite or site collection.
Use SharePointPnPPowerShellOnline
Follow scripts in this blog: https://www.sharepointdiary.com/2019/08/copy-site-using-powershell-pnp-provisioning-template.html