Office 365 – SharePoint – How to debug PnP Provisioning Engine

Quite often I run into issues with PnP templates where something is going wrong but it is unclear what is going wrong. The xml file isn’t generated when I run:

Get-SPOProvisioningTemplate  -Out c:\temp\test.xml

or

Get-PnPProvisioningTemplate  -Out c:\temp\test.xml

And yes I may get an error but it would help if I knew where the command fails.  Similar behaviour you might find when you run the Core PnP libraries from your code in an app or any of the other PnP framework related code.

As this is an open source project it is possible to debug using the code. But there is an easier way. Even when I’m running into issues with the Partner pack I simply revert back to PowerShell.

First step, I’m switching the debug for my PowerShell on

Set-SPOTraceLog -On -Level Debug

or

Set-PnPTraceLog -On -Level Debug

For simplicity sake I’m now only going to run the fields handler:

Get-SPOProvisioningTemplate -Handler Fields  -Out c:\temp\test.xml

or

Get-PnPProvisioningTemplate -Handler Fields  -Out c:\temp\test.xml

This now returns the additional information that you need:

PowerShellPnP

So when an export or import (with Apply-PnPProvisioningTemplate) fails you can see which field, content type or list is the cause of the problem. Once you know what is causing the problem it will be easy to identify what is wrong and why the Provisioning Engine is failing.

If you now still need more details and you want to debug the PnP PowerShell Cmdlets themselves then please have a look at How to debug PnP PowerShell commands


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Avatar of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading