Hi @frob-0826 ,
As there is not any API provided to copy site and save modern site as template has been removed by Microsoft, we can only extracts the site template using PnP PowerShell without its contents. If you only want the structure of the new site collection to be the same as siteB (not including the content of siteB), take a reference to the following steps.
- Get the Source Site Schema XML
This cmdlet gets all artifacts from the source site, such as content types, site columns, term store, list and libraries, theme, pages, etc. into the given template XML file. We also have a switch -includesitegroups to include site security, so that your target site will have unique permissions.$SiteURL = "https://xxx.sharepoint.com/sites/siteA/siteB" $SchmaXMLPath = "C:\temp\SiteSchema.xml" Connect-PnPOnline -Url $siteUrl -UseWebLogin Get-PnPProvisioningTemplate -Out ($SchmaXMLPath) -PersistBrandingFiles -PersistPublishingFiles
- Create a New Site Collection $AdminCenterURL = "https://xxx-Admin.sharepoint.com"
$SiteURL = "https://xxx.sharepoint.com/sites/siteB"
$SiteTitle = "xxx"
$SiteOwner = "xxx@X .onmicrosoft.com"
$Template = "STS#3"
$Timezone = 4 $Cred = Get-Credential Try
{
Connect-PnPOnline -URL $AdminCenterURL -Credential $Cred
}$Site = Get-PnPTenantSite | Where {$_.Url -eq $SiteURL} If ($Site -eq $null) { New-PnPTenantSite -Url $SiteURL -Owner $SiteOwner -Title $SiteTitle -Template $Template -TimeZone $TimeZone -RemoveDeletedSite write-host "Site Collection $($SiteURL) Created Successfully!" -foregroundcolor Green } else { write-host "Site $($SiteURL) exists already!" -foregroundcolor Yellow }
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
} - Apply the Site Schema into Target Site with Apply-PnP ProvisioningTemplate $SiteURL = "https://xxx.sharepoint.com/sites/siteB"
$SchmaXMLPath = "C:\Temp\SiteSchema.xml" Connect-PnPOnline -Url $SiteURL -UseWebLogin Apply-PnPProvisioningTemplate -Path $SchmaXMLPath -ClearNavigation
If you need to copy the site with its content, I'm afraid you have to ask 3rd party migration tools for help.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.