Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-PnPSiteTemplate - Object reference not set to an instance of an object #990

Open
diver7 opened this issue Feb 29, 2024 · 0 comments

Comments

@diver7
Copy link

diver7 commented Feb 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant