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"]
$toSave there is html for WebParts
$toSave html in an text file
then add a page with
then get your page with
set property with your previoulsy save html:
$file.ListItemAllFields["CanvasContent1"] = "your html";
Update and publish your page:
<a href="http://fdi-sharepoint.e-monsite.com">my site</a>