pnp / pnp/pnpframework

Get-PnPSiteTemplate -Out ---- Object reference not set to an instance of an object

Open
#887 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

We are using PSVersion 7.3.4. The below code works with PnP 1.11.0, but not with PnP 2.2.1. This is the only difference. The issue occurs for a more complex site Template; with a fast empty Template it works with any PnP version. Please fix asap, this prevents us from automatical SiteProvisioning that used to work earlier with an old version!!!

$url = "https://mycompany.sharepoint.com/sites/testsite"
$templateUrl = "https://mycompany.sharepoint.com/sites/testsite/template"
$templatePath = "D:\temp\template\template.xml"
$clientid = "777777x7-x7x7-77xx-x777-77xxx77777x7"
$clientSecret = "x7x7xxx.77xxxxxx.xxxxx.x77x~xxx"
$con = Connect-PnPOnline -url $templateUrl -ClientId $clientid -ClientSecret $clientSecret -ReturnConnection
Get-PnPSiteTemplate -Connection $con -Out $templatePath -PersistMultiLanguageResources -Force
Get-PnPException

Message : Object reference not set to an instance of an object.
Stacktrace : at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in
c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 98
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in
c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120
at System.Management.Automation.CommandProcessor.ProcessRecord()
ScriptLineNumber : 1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with Get-PnPSiteTemplate using the complex template and compare PnP 1.11.0 with 2.2.1. Trace the error through PnPConnectedCmdlet.ProcessRecord at c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:98 and PnPSharePointCmdlet.ProcessRecord at line 120. Done means the complex template exports successfully without the null-reference exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.