0

I am trying to install a SPFx Web Part in a Classic SharePoint Online Page using PnP.

First I connect to the tenant

Connect-PnPOnline –Url https://company.sharepoint.com/ –Credentials (Get-Credential)

Then I run this command

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/Company/Pages/CompanyPage.aspx" -Xml "C:\QLWebPart.xml" -ZoneId "Custom Zone" -ZoneIndex 0 

and I get this error:

Add-PnPWebPartToWebPartPage : File Not Found. At line:1 char:1 + Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/Company ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Add-PnPWebPartToWebPartPage], ServerException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.WebParts.AddWebPartToWebPartPage

Which makes no sense because the file exists. I've tried renaming to .xml as well but nothing

What can be wrong?

1 Answer 1

1

The module documentation provides two clear examples for adding a web part to a web part page in a specified zone. You can use the -Path option that defines a path to a web part file on the file system:

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/demo/sitepages/home.aspx" -Path "c:\myfiles\listview.webpart" -ZoneId "Header" -ZoneIndex 1

or -XML option that defines a string containing the XML for the web part:

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/demo/sitepages/home.aspx" -XML $webpart -ZoneId "Header" -ZoneIndex 1

You can find more details here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.