Forum Discussion
Sharepoint Online Templates / Provisioning.
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 BragaNov 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?- Jorge Sottomaior BragaNov 19, 2025Copper Contributor
Sorry for the late reply. It was a question 😊
Yes I'm using with PNP extension and it comes with images when invoking (not sure if that happens with XML... hencec the question...
Following this tutorial.
https://www.youtube.com/watch?v=lK17E412uNgHope this helps.