pnpframework
pnpframework copied to clipboard
Get-PnPSiteTemplate: Object reference not set to an instance of an object.
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
same issue here
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
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.
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 …`