Forum Discussion
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.
3 Replies
Hi Mark Andrada,
This can absolutely be done :)
You will need the Add-PnPWebPartToWebPartPage command as this is the one for classic pages
Check example 2: you will need to create a variable that contains your web part XML and then pass that variable to the command.
Joel
- Mark AndradaCopper ContributorI 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?
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.