SOLVED

Add new SPWeb with Sitescript?

Copper Contributor

Hey there

 

Is there a way to add a new SPWeb (Subsite) via PnPPowerShell (or any other way?) with a site script? I am aware of applying a site script AFTER the creation, but this will cause some unnecessary ootb libraries/notebooks/etc. to be created, rather than just what I need (-> whats in the sitescript).

2 Replies

You can use PnP PowerShell to create a new web (subsite) and delete the libraries and nav nodes you don't need

 

New-PnPWeb

Remove-PnPList

Remove-PnPNavigationNode

 

If you need to do this with a Site Script, you can use the Trigger Flow verb, which can call an Azure Automation PowerShell runbook with PnP PowerShell cmdlets installed which can then use the above cmdlets to delete the unnecessary lists and navigation nodes:

 

PnP Provisioning using Flow and Azure Automation

 

 

 

 

best response confirmed by isabasu (Copper Contributor)
Solution

Be aware that Site Designs and Site Scripts do not work well with sub sites. Sub sites are kind of a "faux pas" in the modern world. If you try to create a subsite, there are many scenarios where the site script will not work (for example, site content types and columns are known to not deploy on subsites)

1 best response

Accepted Solutions
best response confirmed by isabasu (Copper Contributor)
Solution

Be aware that Site Designs and Site Scripts do not work well with sub sites. Sub sites are kind of a "faux pas" in the modern world. If you try to create a subsite, there are many scenarios where the site script will not work (for example, site content types and columns are known to not deploy on subsites)

View solution in original post