pnpframework
pnpframework copied to clipboard
Invoke-PnPSiteTemplate - Object reference not set to an instance of an object
If the site template file (pnp, xml) exists in a sub-folder in a SharePoint document library, Invoke-PnPSiteTemplate will throw the below error.
Invoke-PnPSiteTemplate -Path "https://domain.sharepoint.com/sites/ABCSite/SiteAssets/Templates/template.pnp"
Invoke-PnPSiteTemplate: untitled:Untitled-2:6:1
Line |
6 | Invoke-PnPSiteTemplate -Path "https://domain.sharepoint.com/sites/ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Object reference not set to an instance of an object.
Debug Trace Log:
pwsh Information: 0 : 2024-02-29 08:30:26.5905 [SharePointConnector] [0] [Debug] GetFileStream('template.pnp','siteassets') 0ms
pwsh Error: 0 : 2024-02-29 08:30:26.9198 [PnP.Framework] [0] [Error] ExecuteQuery threw following exception: Microsoft.SharePoint.Client.ServerException: File Not Found.
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServerAsync(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryAsync()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQueryAsync()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQueryAsync()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, String userAgent)
ServerErrorCode: -2147024894
ServerErrorTypeName: System.IO.FileNotFoundException
ServerErrorTraceCorrelationId: 2e7710a1-00b1-4000-ee65-8be8fecb589b
ServerErrorValue:
ServerErrorDetails:
. 0ms
pwsh Error: 0 : 2024-02-29 08:30:26.9207 [PnP.Framework] [0] [Error] File template.pnp not found in site https://domain.sharepoint.com/sites/ABCSite, library siteassets. Exception = File Not Found. 0ms
If the template file is moved to the root of the document library the PnP command runs fine.
Expected behavior
I should be able to place the template file in any sub-folder of the document library
What is the version of the Cmdlet module you are running?
PnP.PowerShell version 2.3.0