Forum Discussion
Vijay Rajagopolan
Nov 07, 2016Copper Contributor
PnP Provisoning to include Sub sites
I am trying to use the provisioning engine from console app. My template is a site collection with few sub sites. When I export my xml I am only seeing the information for the site collection and not seeing the subsites. Is there a limitation or is there a way to include subsites as part of the template? Thank you so much for your help.
Thanks,
Vijay
I agree with Deleted. The reason why you would need to keep your root site is that site columns and content types should live within the root site. Therefore you will find quite often tthat when you update the subsite's template you will also need to reapply the root site as columns/content types could have chnaged.
- nitinkumar kakuldeCopper Contributor
First you need to get template from the Site collection level and then appy the same temaplte to the another site collection or any new tenant. Once it done create sub sites by using below script from the command prompt.
# Reports subsite
Add-Type -Path "C:\Users\navya\Desktop\Retailer Scripts\dlls\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Users\navya\Desktop\Retailer Scripts\dlls\Microsoft.SharePoint.Client.Runtime.dll"
$siteUrl = “https://domainname.sharepoint.com/sites/Subsite”
$username = "admin@domainname.onmicrosoft.com"
$password = Read-Host -Prompt "Password" -AsSecureString$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials$webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$webCreationInformation.Url = "Subsite" //you decide what are sub sites you have and execute by changing this information
$webCreationInformation.Title = "Subsite" //you decide what are sub sites you have and execute by changing this information
$webCreationInformation.WebTemplate = "BLANKINTERNET#2" //You decide what should be your base tempate
$newWeb = $ctx.Web.Webs.Add($webCreationInformation)
$ctx.Load($newWeb)
$ctx.ExecuteQuery()
Write-Host "Title" $newWeb.TitleNow once you create sub sites at targeted tenant, you have to again use get pnp provision temlate and apply provision temaplte by using powershell from tenant to tenant sub site structure migration.
This is how I observed that PnP provision works and we did very successfully work here
Thanks,
Nitinkumar
- DeletedHi Vijay, You have to export all subsites as well it are all seperate templates. if your subsites all look the same you could export 1 subsite. You need to use at least 2 templates 1 for your site collection and 1 for your subsites.. kr, Paul
I agree with Deleted. The reason why you would need to keep your root site is that site columns and content types should live within the root site. Therefore you will find quite often tthat when you update the subsite's template you will also need to reapply the root site as columns/content types could have chnaged.
- Vijay RajagopolanCopper Contributor
Thank you so much that is what I thought but want to make sure the approach is correct and also not missing information that is already out there.
Thanks,
Vijay
Pieter Veenstra wrote:I agree with Deleted. The reason why you would need to keep your root site is that site columns and content types should live within the root site. Therefore you will find quite often tthat when you update the subsite's template you will also need to reapply the root site as columns/content types could have chnaged.