Today I switched back to SharePoint Online, mixing up the releases for the different platforms. I started to export some sites using get-PnPProvisioningTemplate and I got the following error message:powershell_ise.exe Information: 0 : 2017-03-20 14:55:48.3702 [Page Contents] [12] [Debug] Code execution scope started 0ms b4990d80-e2e7-43cb-a4d8-d73c0d5a4b8b powershell_ise.exe Information: 0 : 2017-03-20 14:56:06.5870 [Page Contents] [12] [Debug] Code execution scope ended 18216ms b4990d80-e2e7-43cb-a4d8-d73c0d5a4b8b powershell_ise.exe Information: 0 : 2017-03-20 14:56:06.5895 [Extraction] [12] [Debug] Code execution scope ended 48910ms b4990d80-e2e7-43cb-a4d8-d73c0d5a4b8b Get-PnPProvisioningTemplate : The remote server returned an error: (403) Forbidden. At C:\Workspace\Triad PnP Framework\Triad.FrameWork\Triad.FrameWork.Provisioning\Modules\TriadModules\Modules\Triad.PowerShell.PnPTemplates\Triad.PowerShell.PnPTemplates.psm1:77 char:21 + … Get-PnPProvisioningTemplate -Web $web -Out “$path\Templat … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Get-PnPProvisioningTemplate], WebException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.GetProvisioningTemplateThe nice thing about PnP PowerShell is that you can interchange the templates or at least almost between the on-premises versions of SharePoint and SharePoint Online.As I worked with SharePoint 2013 recently I installed the 2013 version of PnP PowerShell and of course today I didn’t install the Online version of PnP PowerShell.Once I got the right version of PnP installed the error message disappeared.So how do you check version you have installed?Within your PowerShell window run
Get-ModuleThen all modules loaded will be listed.
If you work with SharePoint online you should make sure that you have the following included in the results:Binary 2.13.17… SharePointPnPPowerShellOnline {Add-PnPContentType, Add-PnPContentTypeToDocumentSet, Add-PnPContentTypeToList, Add-PnPCustomAction…}
Frequently asked questions
What caused the 403 error in the author’s test?
The author had installed a SharePoint 2013 PnP PowerShell release while working against SharePoint Online; installing the matching Online release resolved that particular case.
How did the article inspect loaded modules?
It used Get-Module in PowerShell to list loaded modules and check which PnP release was present.
Does every 403 error mean the wrong module is installed?
No. This was one historical cause; also investigate authentication and permissions, and use current PnP PowerShell documentation.
