'invoke-pnpsitetemplate : object reference not set to an instance of an object.

Abhijit Swami 0 Reputation points
2025-02-20T11:06:24.6533333+00:00

Hi all,

We are trying to apply pnp-template by following this article. https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/applying-pnp-templates

I have downloaded the 'theperspectivepnp' from the site and created a 'Mysite' in my tenant. After that I tried the below command

Connect-PnPOnline https://testonlinesite-admin.sharepoint.com/
Invoke-PnPSiteTemplate -Path c:\temp\theperspective.pnp -Parameters @{"SiteUrl"="/sites/Mysite"}

I am getting a below error

'invoke-pnpsitetemplate : object reference not set to an instance of an object.'

Please advise on this.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,324 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 39,116 Reputation points Microsoft Vendor
    2025-02-21T02:34:15.52+00:00

    Hi @Abhijit Swami ,

    As the document mentioned, you could specify {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.

    Invoke-PnPSiteTemplate -Path c:\temp\theperspective.pnp -Parameters @{"SiteTitle"="Mysite";"SiteUrl"="/sites/Mysite"}
    

    Here is the document for reference

    https://pnp.github.io/powershell/cmdlets/Invoke-PnPSiteTemplate.html#example-3


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Abhijit Swami 0 Reputation points
    2025-02-21T04:16:57.14+00:00

    HI @RaytheonXie_MSFT

    Thank you for response but,

    I already have tried using two parameters i,e SiteTitle and SiteUrl, below is the command for the same;

    Invoke-PnPSiteTemplate -Path "D:\n\eclass.pnp" -Parameters @{"SiteTitle"";"SiteUrl"="/sites/"}

    Still getting same issue: Invoke-PnPSiteTemplate: Object reference not set to an instance of an object.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.