sp-starter-kit: Apply-PnPProvisioningTemplate Not Running

Category

  • Question
  • Bug
  • Enhancement

Expected or Desired Behavior

After running .\deploy.ps1 -TenantUrl https://mtcdev0.sharepoint.com -WeatherCity “San Francisco” in PowerShell the demo portal sites should be deployed along with webparts & extensions.

Observed Behavior

Deployment runs successfully up to “Provisioning Solution” at which point the following error is received:

Apply-PnPProvisioningTemplate : Object reference not set to an instance of an object.
At C:\Users\sbglr\Local Documents\sp-starter-kit\provisioning\deploy.ps1:96 char:5
+     Apply-PnPProvisioningTemplate -Path "$PSScriptRoot\solution.xml"  ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], NullReferenceException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

The process continues and a new error pops up shortly after under “Applying template to portal”:

Apply-PnPProvisioningTemplate : Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At C:\Users\sbglr\Local Documents\sp-starter-kit\provisioning\deploy.ps1:124 char:1
+ Apply-PnPProvisioningTemplate -Path "$PSScriptRoot\portal.xml" -Param ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], FormatException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

Sites are successfully created however none of the webparts or extensions seem to be deploying and the site design remains in default configuration.

I’ve attached the output in the attached file “deploy output.txt”. I’ve done my best to make sure pnp is updated, etc but I apologize in advance if I’m missing something silly. Very new to powershell.

Steps to Reproduce

Run .\deploy.ps1 -TenantUrl https://mtcdev0.sharepoint.com -WeatherCity “San Francisco” in PowerShell as admin.

deploy output.txt

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 26 (3 by maintainers)

Most upvoted comments

I have the same issue as @BraunJonathan

Got a few problems trying to make this sample work…

Creating https://cafdoc03.sharepoint.com/sites/testportal
Creating testhr
Creating testmarketing
Provisioning solution
Applying template to portal
WARNING: You specified to remove existing content types for the list with url '/sites/testportal/Lists/Alerts'. We
found a list with the same url in the site. In case of a list update we cannot remove existing content types as they
can be in use by existing list items and/or documents.
Apply-PnPProvisioningTemplate : Accès refusé. Vous n’êtes pas autorisé à effectuer cette action ou à accéder à cette
ressource.
At E:\sp-starter-kit-master\provisioning\deploy.ps1:124 char:1
+ Apply-PnPProvisioningTemplate -Path "$PSScriptRoot\portal.xml" -Param ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerUnauthorizedAccessException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate

Set-PnPSiteDesign : Cannot bind argument to parameter 'Identity' because it is null.
At E:\sp-starter-kit-master\provisioning\deploy.ps1:129 char:29
+ Set-PnPSiteDesign -Identity $teamsitedesign -WebTemplate TeamSite
+                             ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-PnPSiteDesign], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SharePointPnP.PowerShell.Commands.SetSite
   Design

Set-PnPSiteDesign : Cannot bind argument to parameter 'Identity' because it is null.
At E:\sp-starter-kit-master\provisioning\deploy.ps1:131 char:29
+ Set-PnPSiteDesign -Identity $communicationsitedesign -WebTemplate Com ...
+                             ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-PnPSiteDesign], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SharePointPnP.PowerShell.Commands.SetSite
   Design

Updating navigation and applying collab templates
Get-PnPProperty : Cannot bind argument to parameter 'ClientObject' because it is null.
At E:\sp-starter-kit-master\provisioning\deploy.ps1:135 char:43
+ $children = Get-PnPProperty -ClientObject $departmentNode -Property C ...
+                                           ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-PnPProperty], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SharePointPnP.PowerShell.Commands.Base.En
   sureProperty

Cannot index into a null array.
At E:\sp-starter-kit-master\provisioning\deploy.ps1:139 char:9
+         $node = Add-PnPNavigationNode -Location TopNavigationBar -Par ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

I tried quite a few things… I modified the path in the solution.xml file, did the npm i and uploaded the sppkg into my appcatalog before running the script, but it stil doesn’t work… By the way, do you plan to document every webpart and extension independently so we can easily use them on their own or not?

Thanks in advance

I got it working eventually.

Had to put my tenant in to the First Release. I think this is for the API Management piece in the Admin Centre.

I then had to run the below while in the solution folder: npm i gulp bundle –ship gulp package-solution –ship

(Note I got some errors and had to run: npm rebuild node-sass)

Once this was done I ran the script and it worked as expected.

This site was useful: https://beaucameron.net/2018/05/22/pnp-sp-starter-kit-hints-and-tips/?utm_source=collab365&utm_medium=collab365today&utm_campaign=daily_digest

Hi. If someone get an error of access denied during the execution of the template with Portal.xml like the following message:

Apply-PnPProvisioningTemplate : Access Denied… At line:1 char:1

  • Apply-PnPProvisioningTemplate -Path .\portal.xml -Parameters @{"Weath …
  •   + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerUnauthorizedAccessException
      + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.ApplyProvisioningTemplate
    
    

you should enable the custom code execution on your tenant

Set-SPOsite <SiteURL> -DenyAddAndCustomizePages 0

Official documentation: https://support.office.com/en-us/article/allow-or-prevent-custom-script-1f2c515f-5d7e-448a-9fd7-835da935584f

I found the issue with the trace enabled while applying the template (Set-PnPTraceLog -On -Level Debug)

powershell.exe Warning: 0 : 2018-06-28 12:25:28.9539 [List instances] [14] [Information] Skip adding/upda ting custom actions because the site has “noscript” enabled. 6569ms 12e06483-d730-41a9-b091-dccb00d7e90a

The issue is raised when trying to create the PPTX file on Site Assests.

Well, hope this finding is usefull for someone.

Grettings!

I have this same issue, but only with the SPFx-LOB* items. I’ve ignored it and most things seem to work anyway. Having said that I’m not sure what functionality the LOB permissions are supposed to support…