Forum Discussion
Maverick1812
Nov 10, 2025Copper Contributor
Sharepoint Online Templates / Provisioning.
Hello everyone, I have a SharePoint online site that is as close as possible to being a template for my tenant. I'd like to save this site and make it available to me when I need to create a standar...
Maverick1812
Nov 12, 2025Copper Contributor
Thank you for the reply, very much appreciated. I managed to write a script that does work; however, for some reason, it doesn't copy the homepage, so it copies the structure, views, contents, but not the pages and the site design.
#SOURCE
$sourceSiteUrl = "Source Site.com"
#TARGET
$targetSiteUrl = "Targetsite.com"
#connect to source site
Connect-PnPOnline -Url $sourceSiteUrl -ClientId xxxxxx-xxxxx-xxxxxxxxx -Interactive
#Export site template
Get-PnPSiteTemplate -Out "NewtestSiteTemplate.xml"
-Handlers Pages, Navigation `
-IncludeAllClientSidePages `
-PersistBrandingFiles
#connect to target site
Connect-PnPOnline -Url $targetSiteUrl -ClientId xxxxxx-xxxxx-xxxxxxxxx -Interactive
# System lists/libraries that should be skipped when checking/creating lists
$systemLists = @(
"Site Pages",
"Documents",
"AppData",
"User Information List",
"Master Page Gallery",
"Style Library",
"Theme Gallery",
"Solution Gallery",
"TaxonomyHiddenList",
"Web Part Gallery"
)
#existing list check
Get-PnPList | ForEach-Object {
if ($systemLists -contains $_.Title) {
Write-Host "Skipping system list: $($_.Title)" -ForegroundColor Yellow
}
else {
Write-Host "List exists (non-system): $($_.Title)" -ForegroundColor Green
}
}
# The -ClearNavigation flag resets existing navigation before applying navigation from the template.
Invoke-PnPSiteTemplate -Path "NewtestSiteTemplate.xml" -ClearNavigation
# Set the home page (default page) on TARGET
Set-PnPHomePage -RootFolderRelativeUrl "SitePages/CollabHome.aspx"
Jorge Sottomaior Braga
Nov 13, 2025Copper Contributor
Shouldn't you use PNP(instead of XML) as export to get images and stuff?
- Maverick1812Nov 13, 2025Copper Contributor
I honestly don't know, you thinkl I should just modify the output file extension?
- Maverick1812Nov 13, 2025Copper Contributor
I don't know to be honest, should I just change the output file extension?
- Maverick1812Nov 13, 2025Copper Contributor
Hi Jorge, thanks for your reply, I'm not quite sure tbh, It's the first time I'm attempting this.
Should I simply change the file extension of the output file?