It’s not often that I work with SharePoint on-premises anymore, but recently I had a look at PnP PowerShell for SharePoint 2013.
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.GetProvisioningTemplate
The 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-Module
Then 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…}