SOLVED

PnP Provisoning to include Sub sites

Copper Contributor

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

5 Replies
Hi 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
best response confirmed by Vijay Rajagopolan (Copper Contributor)
Solution

@Vijay Rajagopolan,

 

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.

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:

@Vijay Rajagopolan,

 

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.


 

Hi Team,

 

I am able to migrate the site structure of Site collection to another site collection of other teanant in SharePOint online but same is not working for sub site to sub site misite structure migration using below PnP Get and Apply provisiontemplate command 

 

Connect-SPOnline -Url https://domainName.sharepoint.com/Sites/TT1/SubSite -Credential DEV #(Get-Credential)
Apply-SPOProvisioningTemplate -Path .\RetailerExtranetQARootSiteStructureToTSW_2.xml

 

In PowerShell it shows logs that lists and CT created but actually its not create anything at subsite level. 

 

 

Site collection level migration working perfect by executinge below command 

 

Connect-SPOnline -Url https://domainName.sharepoint.com/Sites/TT1 -Credential DEV #(Get-Credential)
Apply-SPOProvisioningTemplate -Path .\SiteCollectionLevelStructure.xml

 

Your help would be appreciated. Please let me know as soon as possible where is the problem.

@Vijay Rajagopolan

 

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

1 best response

Accepted Solutions
best response confirmed by Vijay Rajagopolan (Copper Contributor)
Solution

@Vijay Rajagopolan,

 

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.

View solution in original post