Forum Discussion
PnP Provisoning to include Sub sites
- Nov 08, 2016
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.
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.Title
Now 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