powershell
powershell copied to clipboard
[BUG] _Get-PnPSiteTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl_
Reporting an Issue
The issue is on below command
Get-PnPSiteTemplate -Out $exportTemplatePath -IncludeAllClientSidePages -PersistBrandingFiles
failing with error
Get-PnPSiteTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl
Expected behavior
Export should be completed
Actual behavior
If we have any OOTB web part Button in one of the Client-side pages and the link is pointing to a URL that is absolute as in some external site/link (like https://somedomain.com) the Get-PnPSiteTemplate command is not working properly
Get-PnPSiteTemplate -Out $exportTemplatePath -IncludeAllClientSidePages -PersistBrandingFiles We are getting below error
Get-PnPSiteTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl
Additional information If we modify the web page and change the link to something from the same site, the export command executes successfully...
Steps to reproduce behavior
- Create a client-side page and add OOTB web part Button and configure web part to point to external domain link
- Try to run the below command to export the template which includes client-side pages.
Get-PnPSiteTemplate -Out $exportTemplatePath -IncludeAllClientSidePages -PersistBrandingFiles 3. We will get below error
What is the version of the Cmdlet module you are running?
1.6.0 PnP.PowerShell
Which operating system/environment are you running PnP PowerShell on?
- [x ] Windows
@siddharth-vaghasia - Can you update first to 1.8.0
and also the nightly release and feedback please.
I can confirm this issue when using the -PersistBrandingFiles switch. I'm on version 1.8.0
@siddharth-vaghasia , @SVG4365 - can you please try with the 1.9.0 release and let us know ? I was not able to reproduce it with the latest version.
Closing as no response.
@veronicageek can we reopen this issue? I experience the same when using the -IncludeAllClientSidePages parameter. I am using v1.9.0
For one site, I can't export to file at all, but only -PersistBrandingFiles breaks when using -OutputInstance.
Seems to be breaking at [Client Side Page Contents]:
powershell.exe Information: 0 : 2022-05-04 01:37:49.9349 [Features] [12] [Debug] Code execution scope started 0ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:50.2559 [Features] [12] [Debug] Code execution scope ended 320ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:50.3339 [Search Settings] [12] [Debug] Code execution scope started 0ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:53.5589 [Search Settings] [12] [Debug] Code execution scope ended 3224ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:53.6379 [Page Contents] [12] [Debug] Code execution scope started 0ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:54.0019 [Page Contents] [12] [Debug] Code execution scope ended 364ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:54.0810 [Client Side Page Contents] [12] [Debug] Code execution scope started 0ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Error: 0 : 2022-05-04 01:37:56.1709 [PnP.Framework] [0] [Error] ExecuteQuery threw following exception: Microsoft.SharePoint.Client.ServerException: Server relative urls must start with SPWeb.ServerRelativeUrl at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__65.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__28.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__6.MoveNext() ServerErrorCode: -2147024809 ServerErrorTypeName: System.ArgumentException ServerErrorTraceCorrelationId: 67e739a0-005b-4000-030e-ddff425cec7b ServerErrorValue: ServerErrorDetails: . 0ms powershell.exe Information: 0 : 2022-05-04 01:37:56.1749 [Client Side Page Contents] [12] [Debug] Code execution scope ended 2093ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 powershell.exe Information: 0 : 2022-05-04 01:37:56.1759 [Extraction] [12] [Debug] Code execution scope ended 89099ms 479f5a78-6e4c-479d-af4c-cb8e15e3ddc9 Get-PnPSiteTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl At line:1 char:2
- Get-PnPSiteTemplate -Out $siteTemplateOutPath -ListsToExtract $listI ...
-
+ CategoryInfo : WriteError: (:) [Get-PnPSiteTemplate], ServerException + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate
Trying to save the apparently successful -OutputInstance extract, I get this (templatesimpel.pnp is created without .resx in it - and no reference to a .resx from files-map.xml):
Save-PnPSiteTemplate -Template $pnpSiteTemplate -Out $siteTemplateOutPath -Verbose powershell.exe Error: 0 : 2022-05-04 01:55:18.2900 [PnP.Framework] [0] [Error] File C:\Users\rune\Desktop\SiteTemplateTest\templatesimpel.pnp not found in directory . Exception = Could not find file 'C:\Users\rune\Desktop\SiteTemplateTest\templatesimpel.pnp'. 0ms powershell.exe Information: 0 : 2022-05-04 01:55:18.6730 [PnP.Framework] [0] [Information] File templatesimpel.xml saved to folder 0ms powershell.exe Information: 0 : 2022-05-04 01:55:18.9220 [PnP.Framework] [0] [Information] File C:\Users\rune\Desktop\SiteTemplateTest\templatesimpel.pnp saved to folder 0ms powershell.exe Information: 0 : 2022-05-04 01:55:18.9289 [PnP.Framework] [0] [Information] File templatesimpel.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2022-05-04 01:55:18.9299 [PnP.Framework] [0] [Information] File templatesimpel.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2022-05-04 01:55:19.0300 [PnP.Framework] [0] [Information] File templatesimpel.xml retrieved from folder 0ms Processing PnP_Resources.da-DK.resx powershell.exe Error: 0 : 2022-05-04 01:55:19.2049 [PnP.Framework] [0] [Error] File PnP_Resources.da-DK.resx not found in directory . Exception = Could not find file 'C:\Users\rune\Desktop\SiteTemplateTest\PnP_Resources.da-DK.resx'. 0ms Save-PnPSiteTemplate : Value cannot be null. Parameter name: stream At line:1 char:1
- Save-PnPSiteTemplate -Template $pnpSiteTemplate -Out $siteTemplateOut ...
-
+ CategoryInfo : NotSpecified: (:) [Save-PnPSiteTemplate], ArgumentNullException + FullyQualifiedErrorId : System.ArgumentNullException,PnP.PowerShell.Commands.Provisioning.SaveSiteTemplate
And when disabling -PersistMultiLanguageResources, I get this. I'm beginning to think it's a localization issue...
powershell.exe Information: 0 : 2022-05-04 02:07:06.7833 [PnP.Framework] [0] [Information] File C:\Users\rune\Desktop\SiteTemplateTest\templatesimpel.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2022-05-04 02:07:07.0064 [PnP.Framework] [0] [Information] File templatesimpel.xml saved to folder 0ms powershell.exe Information: 0 : 2022-05-04 02:07:07.0193 [PnP.Framework] [0] [Information] File C:\Users\rune\Desktop\SiteTemplateTest\templatesimpel.pnp saved to folder 0ms powershell.exe Information: 0 : 2022-05-04 02:07:07.0284 [PnP.Framework] [0] [Information] File templatesimpel.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2022-05-04 02:07:07.0293 [PnP.Framework] [0] [Information] File templatesimpel.pnp retrieved from folder 0ms powershell.exe Information: 0 : 2022-05-04 02:07:07.0503 [PnP.Framework] [0] [Information] File templatesimpel.xml retrieved from folder 0ms Save-PnPSiteTemplate : Illegal characters in path. At line:1 char:1
- Save-PnPSiteTemplate -Template $pnpSiteTemplate -Out $siteTemplateOut ...
-
+ CategoryInfo : NotSpecified: (:) [Save-PnPSiteTemplate], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,PnP.PowerShell.Commands.Provisioning.SaveSiteTemplate
Hum, persistAssetTiles breaks Get-PnPTenantTemplate in the same way for the same site.
powershell.exe Information: 0 : 2022-05-04 17:07:53.7392 [Client Side Page Contents] [12] [Debug] Code execution scope started 0ms c8aa709a-520d-4977-bafb-f62bde28f21a powershell.exe Error: 0 : 2022-05-04 17:07:56.0122 [PnP.Framework] [0] [Error] ExecuteQuery threw following exception: Microsoft.SharePoint.Client.ServerException: Server relative urls must start with SPWeb.ServerRelativeUrl at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryToServerAsync>d__53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRequest.<ExecuteQueryAsync>d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientRuntimeContext.<ExecuteQueryAsync>d__65.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SharePoint.Client.ClientContext.<ExecuteQueryAsync>d__28.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.SharePoint.Client.ClientContextExtensions.<ExecuteQueryImplementation>d__6.MoveNext() ServerErrorCode: -2147024809 ServerErrorTypeName: System.ArgumentException ServerErrorTraceCorrelationId: 9e1c3aa0-c05b-4000-1d58-f6e534a14d2b ServerErrorValue: ServerErrorDetails: . 0ms powershell.exe Information: 0 : 2022-05-04 17:07:56.0162 [Client Side Page Contents] [12] [Debug] Code execution scope ended 2276ms c8aa709a-520d-4977-bafb-f62bde28f21a powershell.exe Information: 0 : 2022-05-04 17:07:56.0162 [Extraction] [12] [Debug] Code execution scope ended 66326ms c8aa709a-520d-4977-bafb-f62bde28f21a powershell.exe Information: 0 : 2022-05-04 17:07:56.0172 [Extraction] [12] [Debug] Code execution scope ended 68306ms c8aa709a-520d-4977-bafb-f62bde28f21a Get-PnPTenantTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl At line:7 char:19
- ... tTemplate = Get-PnPTenantTemplate -Out $tenantTemplateOutPath -Config ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : WriteError: (:) [Get-PnPTenantTemplate], ServerException
- FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.GetTenantTemplate
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
I am facing the same issue
I am also facing the same issue when I have some external URL on the page.
@Arun-Ravi @abhijeet-chatarjee - Can you please update to the latest release 2.1.x
however you will need PS 7.2 or later to benefit from all the bug fixes and improvements.
PS5 support has been dropped in the new release.
This is still a problem after upgrading to PS 7.2 and module 2.1.1.
We also see the same problem in an Azure powershell runbook which we assume is version 2.1.1 since that is shown on Modules → Add a module → Browse Gallery → PnP.PowerShell, but importing this module shows "Unknown" under Module version for every tenant we tried (4).
Can somebody please tell if this issue still persists ? I was unable to reproduce this. Would be great if you can share you exact steps to reproduce this, preferably in a brand new site collection. Tried various combinations of external links and webparts but the template is always extracted without errors.
I am using the latest 2.1.1 version in PS 7.2
Closing as no response.
Hi, I am facing the same issue. I'm using PnP.PowerShell Version 2.2.0
@veronicageek @gautamdsheth Could you please reopen this bug?
Also having the issue.
@veronicageek - we can’t reproduce it , not sure what we can do here .
@Jamiet19 - how can we reproduce this ? Tried with above mentioned steps , can’t repro
Closing again as we can't reproduce and no response. If anyone has the problem, please open a new issue with the steps.
Hi, I am facing the same issue. I'm using PnP.PowerShell Version 2.2.0
@veronicageek @gautamdsheth Could you please reopen this bug?
I did a couple of test cases, and I would like to share that with you hopefully that would guide us to catch the root cause of the issue.
When I run the command
$baseTemplate = Get-PnPSiteTemplate -IncludeAllClientSidePages -Handlers PageContents, Pages -OutputInstance -Schema LATEST -PersistBrandingFiles
I see that yellow logging showing the pages one by one and when it comes to specific page it throws the
error: "Get-PnPSiteTemplate: Server relative urls must start with SPWeb.ServerRelativeUrl".
Once, I delete the page then run it again, it throws the error for another page. When I copy one the pages that causing the issue to another site, it causes the issue to the site it has copied.
Hello ! I had a page that caused this issue. It had a button WebPart linking outside the site. Removing that button fixed the issue. Hope this helps track down the problem.
Well, Thanks for the update @nathan-prijot @gautamdsheth Could you please reproduce this scenario and if it's the root cause then please help us fixing it.
Hey @veronicageek , @gautamdsheth, @nathan-prijot I've found the root cause of the issue, hopefully that you will fix it soon.
When using -PersistBrandingFiles
to generates a provisioning site template, It extracts a provisioning template in Office Open XML from the current web and saves the files that make up the composed look to the same folder as where the template is saved.
If you have images in your pages that are outside SharePoint Tenant, then you will have this error Get-PnPSiteTemplate: Server relative URLs must start with SPWeb.ServerRelativeUrl
I got this error for the pages that have images source outside the tenant, Ex: "imageSource": "https://cdn.hubblecontent.osi.office.net/m365content/publish/...../541976840.jpg"
Temp fix could be by: Removing -PersistBrandingFiles parameter Make sure that images of image webparts and page header webparts' images are saved in the Tenant and not in external CDN.