pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Can you using 'Add-PnPClientSideWebPart' to add text web part #1337

Closed raymondlittle100 closed 6 years ago

raymondlittle100 commented 6 years ago

Reporting an Issue or Missing Feature

Question

Question

I'm trying to write a script to add web parts to a modern page using 'PnP PowerShell for SharePoint Online'. I have the page creation and section setup done but now I'm trying to add web parts. I'm using 'Add-PnPClientSideWebPart' and this works fine for custom web parts but when trying to add text I can't see how to set the text. I even added the Text web part to the workbench to see if i could see the web part properties but there were none.

My question is can I use the generic 'Add-PnPClientSideWebPart' function or do I have to use the more specific 'Add-PnPClientSideText' function?

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

2.22.1801.0

How did you install the PnP-PowerShell Cmdlets?

wobba commented 6 years ago

Yes, see sample at https://hangconsult.com/2017/11/05/creating-a-new-client-side-page-with-pnp-powershell/

patrickabel commented 5 years ago

@wobba Is there a way to use the Add-PnPClientSideWebPart cmdlet as opposed to Add-PnPClientSideText for adding text web-parts to modern SPO pages via PS?

I'd like to be able to set the innerHTML property in the same way I can when doing something like: Add-PnPClientSideWebPart -Page "SomePage" -DefaultWebPartType List -WebPartProperties $templateWebPartProps

Any ideas?

patrickabel commented 5 years ago

nvm, looks like I dump HTML into the -Text property!

wobba commented 5 years ago

@patrickabel the text webpart is not a webpart per say - behaves a bit different. And glad you sorted it out. Beware of what you dump and how it possibly can change in edit mode.