I am dynamically creating sites (Modern sites/pages) and I want to add embed
webpart with embedded code each time a site gets created.
How can I do that with PnP Powershell script?
you should create a test page with all your web parts
then with pnp get your page as file
$toSave = $file.ListItemAllFields["CanvasContent1"]
in $toSave
there is html for WebParts
put $toSave
html in an text file
then add a page with Add-PnPClientSidePage
then get your page with Get-PnPClientSidePage
set property with your previoulsy save html:
$file.ListItemAllFields["CanvasContent1"] = "your html";
Update and publish your page:
[http://fdi-sharepoint.e-monsite.com][1]