Forum Discussion

Mark Andrada's avatar
Mark Andrada
Copper Contributor
Mar 08, 2018

PnP PowerShell - Adding SPFx web part to a 'classic' page

Using PnP PowerShell, I'm able to add a .dwp or .webpart file to my page using Add-PnPWebPartToWebPartPage.

I can also add an SPFx client side web part to a 'modern' page using Add-PnPClientSideWebPart.

 

Is there a way then using PnP to add an SPFx client side web part to a 'classic' page?

 

I found a hacky way by manually adding the client side web part to the 'classic' page, exporting it to get the .webpart file and using Add-PnPWebPartToWebPartPage to add that file programmatically.

  • Hi Mark Andrada,

     

    No problem, other commands will help here.

     

    Start by adding the web part to a page.

    Next, execute Get-PnPWebPart to get all the web parts on the page and identify the Id for the one you need to export as XML

    Finally, use Get-PnPWebPartXml to get the XML for the web part (passing the correct Id)

     

    Let me know if you find any problems, but it should be very easy to complete.

     

    • Mark Andrada's avatar
      Mark Andrada
      Copper Contributor
      I guess I'm a bit confused still. I have the client web part app added and installed on my site collection app catalog. How would I get the XML from here?
      • Joel Rodrigues's avatar
        Joel Rodrigues
        MVP

        Hi Mark Andrada,

         

        No problem, other commands will help here.

         

        Start by adding the web part to a page.

        Next, execute Get-PnPWebPart to get all the web parts on the page and identify the Id for the one you need to export as XML

        Finally, use Get-PnPWebPartXml to get the XML for the web part (passing the correct Id)

         

        Let me know if you find any problems, but it should be very easy to complete.

         

Resources