SOLVED

PnP Get-PnPProvisioningTemplate subsite - 403 error

New Contributor

Hi,

 

I'm trying to extract a template from a subsite in my site collection.

But I get an (403) Forbidden error.

With tracelog on I see it is at Lists level:

powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	Code execution scope started	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	Base template available: STS0template	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	ProgressDelegate registered	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.0368	[Extraction]	[13]	[Debug]	MessagesDelegate registered	1ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:51.3040	[List instances]	[13]	[Debug]	Code execution scope started	0ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Error: 0 : 2018-02-21 10:05:53.2420	[OfficeDevPnP.Core]	[0]	[Error]	ExecuteQuery threw following exception: System.Net.WebException: The remote server returned
 an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
   at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
   at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
   at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay, String userAgent).	0ms	
powershell_ise.exe Information: 0 : 2018-02-21 10:05:53.2540	[List instances]	[13]	[Debug]	Code execution scope ended	1976ms	bf94329c-d433-47fd-88cf-825b011b6939
powershell_ise.exe Information: 0 : 2018-02-21 10:05:53.2550	[Extraction]	[13]	[Debug]	Code execution scope ended	2245ms	bf94329c-d433-47fd-88cf-825b011b6939

Any ideas why I get the 403?

I've tried with newly created clean subsite and have the same error.

If I try to get the template of the Site Collection itself it works. Only subsites give the error.

 

Thanks,

Peter

1 Reply
best response confirmed by Peter ... (New Contributor)
Solution

I'm using  -UseWebLogin to connect (due to local environment).

Apparently this gives errors for subsites.

With another authentication method it seems to work.