Error finding PnP profile when executing Invoke-PnPSiteTemplate command

壹涵 雷 0 Reputation points
2024-05-10T13:42:29.7766667+00:00

I followed the installation guide mentioned here and successfully connected to the SharePoint online tenant using the following PowerShell command:

Connect-PnPOnline https://<tenant>-admin.sharepoint.com/

Then, I executed the Invoke-PnPSiteTemplate command to apply the PnP Site Template, but encountered an error that the specified file does not exist. Upon searching, I found that the root directory did not exist at all.

I have attached the relevant error screenshots for reference.

0f411885-27b9-4121-817a-0905a194816c

f334b55f-1cfd-47dc-9eda-1ce1b55b0748

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,913 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,185 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 45,186 Reputation points
    2024-05-10T15:22:46.0133333+00:00

    The path ".\your-template-file.pnp" implies that you're using the current directory. If that's the root of the drive "D:", and the screenshot of file explorer (I'm assuming what it is) is of that drive then it shows that there's no such file there -- or that it's hidden or system file and you haven't configured the file explorer to show all files.

    Do you see the file when you run the cmdlet below?

    Get-ChildItem -Path D:\* -Force
    
    0 comments No comments

  2. Emily Du-MSFT 42,821 Reputation points Microsoft Vendor
    2024-05-13T07:44:45.24+00:00

    Please try to use below PnP PowerShell to apply theme for a SharePoint site.

    #Config Variables
    $SiteURL = "https://tenant.sharepoint.com/sites/emilytest"
    $TemplateXML  ="D:\PnP-Theme.xml"
      
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
     
    #Apply provisioning Template
    Invoke-PnPSiteTemplate -path $TemplateXML
    

    Note: You should run PowerShell as administrator.


    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.