0

I have used PowerShell many times to export a SharePoint site and load to a new site.

However I am now getting the following error message:

get-pnpsitetemplate : server relative urls must start with spweb.serverrelativeurl

The only change I have made was to rename the site and to change the location address of the site in SharePoint Admin, all was confirmed as good and the site works as expected with the name and address. But trying to export now delivers the error message.

The script is as follows:

$url = "https://xxxxx.sharepoint.com/sites/CustomerPortal"

Connect-PnPOnline -Url $url -Interactive

Get-PnPSiteTemplate -Configuration "C:\xxxx\xxxxxx\config.json" -Out "C:\xxxxx\xxxxx\Template.xml"

Disconnect-PnPOnline

the config.json looks like this.

{
"$Schema": "https://aka.ms/sppnp-configuration-schema",
"handlers": [
"Lists",
"WebSettings",
"Pages",
"Fields",
"Navigation",
"Files",
"Theme",
"SiteHeader",
"SiteFooter"
],
"pages": {
"excludeAuthorInformation": true,
"includeAllClientSidePages": true
},
"lists": {
"lists": [
{
"includeItems": true,
"title": "Events"
},
{
"includeItems": true,
"title": "Photo Gallery"
},
{
"includeItems": true,
"title": "Documents"
}
]
},
"navigation": {
"removeExistingNodes": true
},
"persistAssetFiles": true,
"siteSecurity": {"includeSiteGroups": false}

Is there a line I can add to the config.json that will handle the problem or do I need to add a line to the script?

1 Answer 1

0

Based on the fact that you have renamed the URL of the site and that the error points to a wrong relative URL it would be my guess that its not your script or config file that needs to be updated, but rather something on the site it self that broke during the renaming of the URL. Are there for instances any custom solutions on the site that stopped working since it did get the URL updated? This could also break the export of the site template.

If it was me that had the same error I would start by doing one handler at a time (update the config file to only take lists for instance, and then take sites etc etc) and see where the export breaks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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