pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

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

Open VengefulSloth opened this issue 1 year ago • 4 comments

I am working on exporting a complex list, but I am running into this issue. PS 7.3.9 PNP.PowerShell 2.2.0

PS C:\Windows\System32> Get-PnPSiteTemplate -Out $TemplateFile -ListsToExtract $ListName -Handlers Lists Get-PnPSiteTemplate: Object reference not set to an instance of an object. PS C:\Windows\System32> 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 101 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120 at System.Management.Automation.CommandProcessor.ProcessRecord() ScriptLineNumber : 1

VengefulSloth avatar Nov 03 '23 16:11 VengefulSloth

same issue here

0iron0 avatar Nov 23 '23 05:11 0iron0

Similar issue - this is trying to extract -Handlers Fields Get-PnPSiteTemplate -out SandboxSite-FieldsContentType.xml -Handlers Fields,ContentTypes also if I issue: Get-PnPSiteTemplate -out SandboxSite-Fields.xml -Handlers Fields

❯ 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 101 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 120 at System.Management.Automation.CommandProcessor.ProcessRecord() ScriptLineNumber : 1

dantshin avatar Jan 22 '24 15:01 dantshin

Any news on this? I got the same error when calling Get-PnPSiteTemplate -Out ($exportedTemplateFile) The Extract progress bar does everything, after this the error occur.

Edit: I just found out, that in my case a faulty url of the source site was the problem. By mistake I created the source site with special chars in url e.g. " .../sites/MySource(Site)Url. After renamed the url, and the Template was created without errors.

Checking this at template creation and returning a clear error would be helpful in future releases.

Myjestic avatar Mar 26 '24 08:03 Myjestic

I have the same issue today.

I can confirm that I do NOT have any special characters in the Url at all, or indeed in any other asset within the site.

I have also tried excluding some potentially problematic assets like PageContents, SiteSecurity, but ALWAYS: "Object reference is not set to an instance of an object".

Get-PnPException returns: 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 101 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 131 at System.Management.Automation.CommandProcessor.ProcessRecord() ScriptLineNumber : 1

(Exactly the same error as described in op)

$PSVersionTable

`Name Value


PSVersion 7.4.4 PSEdition Core GitCommitId 7.4.4 OS Debian GNU/Linux 12 (bookworm) Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0`

Get-Module -ListAvailable

`ModuleType Version PreRelease Name PSEdition ExportedCommands


Binary 16.0.2511… Microsoft.Online.SharePoint.PowerS… Desk
Manifest 2.5.0 PnP.PowerShell Core …`

jh-sigmadx avatar Aug 14 '24 08:08 jh-sigmadx