SOLVED
Home

PnP Provisoning to include Sub sites

%3CLINGO-SUB%20id%3D%22lingo-sub-27865%22%20slang%3D%22en-US%22%3EPnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27865%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20use%20the%20provisioning%20engine%20from%20console%20app.%20My%20template%20is%20a%20site%20collection%20with%20few%20sub%20sites.%20When%20I%20export%20my%20xml%20I%20am%20only%20seeing%20the%20information%20for%20the%20site%20collection%20and%20not%20seeing%20the%20subsites.%20Is%20there%20a%20limitation%20or%20is%20there%20a%20way%20to%20include%20subsites%20as%20part%20of%20the%20template%3F%20Thank%20you%20so%20much%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EVijay%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37436%22%20slang%3D%22en-US%22%3ERe%3A%20PnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37436%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28876%22%20target%3D%22_blank%22%3E%40Vijay%20Rajagopolan%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%20you%20need%20to%20get%20template%20from%20the%20Site%20collection%20level%20and%20then%20appy%20the%20same%20temaplte%20to%20the%20another%20site%20collection%20or%20any%20new%20tenant.%20Once%20it%20done%20create%20sub%20sites%20by%20using%20below%20script%20from%20the%20command%20prompt.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23%20Reports%20subsite%3CBR%20%2F%3EAdd-Type%20-Path%20%22C%3A%5CUsers%5Cnavya%5CDesktop%5CRetailer%20Scripts%5Cdlls%5CMicrosoft.SharePoint.Client.dll%22%3CBR%20%2F%3EAdd-Type%20-Path%20%22C%3A%5CUsers%5Cnavya%5CDesktop%5CRetailer%20Scripts%5Cdlls%5CMicrosoft.SharePoint.Client.Runtime.dll%22%3CBR%20%2F%3E%24siteUrl%20%3D%20%E2%80%9C%3CA%20href%3D%22https%3A%2F%2Fdomainname.sharepoint.com%2Fsites%2FSubsite%E2%80%9D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdomainname.sharepoint.com%2Fsites%2FSubsite%E2%80%9D%3C%2FA%3E%3CBR%20%2F%3E%24username%20%3D%20%22admin%40domainname.onmicrosoft.com%22%3CBR%20%2F%3E%24password%20%3D%20Read-Host%20-Prompt%20%22Password%22%20-AsSecureString%3C%2FP%3E%3CP%3E%24ctx%20%3D%20New-Object%20Microsoft.SharePoint.Client.ClientContext(%24siteUrl)%3CBR%20%2F%3E%24credentials%20%3D%20New-Object%20Microsoft.SharePoint.Client.SharePointOnlineCredentials(%24username%2C%20%24password)%3CBR%20%2F%3E%24ctx.Credentials%20%3D%20%24credentials%3C%2FP%3E%3CP%3E%24webCreationInformation%20%3D%20New-Object%20Microsoft.SharePoint.Client.WebCreationInformation%3CBR%20%2F%3E%24webCreationInformation.Url%20%3D%20%22Subsite%22%20%2F%2Fyou%20decide%20what%20are%20sub%20sites%20you%20have%20and%20execute%20by%20changing%20this%20information%26nbsp%3B%3CBR%20%2F%3E%24webCreationInformation.Title%20%3D%20%22Subsite%22%26nbsp%3B%3CSPAN%3E%2F%2Fyou%20decide%20what%20are%20sub%20sites%20you%20have%20and%20execute%20by%20changing%20this%20information%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%24webCreationInformation.WebTemplate%20%3D%20%22BLANKINTERNET%232%22%20%2F%2FYou%20decide%20what%20should%20be%20your%20base%20tempate%26nbsp%3B%3CBR%20%2F%3E%24newWeb%20%3D%20%24ctx.Web.Webs.Add(%24webCreationInformation)%3CBR%20%2F%3E%24ctx.Load(%24newWeb)%3CBR%20%2F%3E%24ctx.ExecuteQuery()%3CBR%20%2F%3EWrite-Host%20%22Title%22%20%24newWeb.Title%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20once%20you%20create%20sub%20sites%20at%20targeted%20tenant%2C%20you%20have%20to%20again%20use%20get%20pnp%20provision%20temlate%20and%20apply%20provision%20temaplte%20by%20using%20powershell%20from%20tenant%20to%20tenant%20sub%20site%20structure%20migration.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20how%20I%20observed%20that%20PnP%20provision%20works%20and%20we%20did%20very%20successfully%20work%20here%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3ENitinkumar%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37262%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20PnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37262%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20able%20to%20migrate%20the%20site%20structure%20of%20Site%20collection%20to%20another%20site%20collection%20of%20other%20teanant%20in%20SharePOint%20online%20but%20same%20is%20not%20working%20for%20sub%20site%20to%20sub%20site%20misite%20structure%20migration%20using%20below%20PnP%20Get%20and%20Apply%20provisiontemplate%20command%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-SPOnline%20-Url%20%3CA%20href%3D%22https%3A%2F%2FdomainName.sharepoint.com%2FSites%2FTT1%2FSubSite%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2FdomainName.sharepoint.com%2FSites%2FTT1%2FSubSite%3C%2FA%3E%20-Credential%20DEV%20%23(Get-Credential)%3CBR%20%2F%3EApply-SPOProvisioningTemplate%20-Path%20.%5CRetailerExtranetQARootSiteStructureToTSW_2.xml%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20PowerShell%20it%20shows%20logs%20that%20lists%20and%20CT%20created%20but%20actually%20its%20not%20create%20anything%20at%20subsite%20level.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESite%20collection%20level%20migration%20working%20perfect%20by%20executinge%20below%20command%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-SPOnline%20-Url%20%3CA%20href%3D%22https%3A%2F%2FdomainName.sharepoint.com%2FSites%2FTT1%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2FdomainName.sharepoint.com%2FSites%2FTT1%3C%2FA%3E%20-Credential%20DEV%20%23(Get-Credential)%3CBR%20%2F%3EApply-SPOProvisioningTemplate%20-Path%20.%5CSiteCollectionLevelStructure.xml%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20help%20would%20be%20appreciated.%20Please%20let%20me%20know%20as%20soon%20as%20possible%20where%20is%20the%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-28006%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20PnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-28006%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20that%20is%20what%20I%20thought%20but%20want%20to%20make%20sure%20the%20approach%20is%20correct%20and%20also%20not%20missing%20information%20that%20is%20already%20out%20there.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EVijay%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%20wrote%3A%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28876%22%20target%3D%22_blank%22%3E%40Vijay%20Rajagopolan%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20agree%20with%26nbsp%3B%40Deleted.%20The%20reason%20why%20you%20would%20need%20to%20keep%20your%20root%20site%20is%20that%20site%20columns%20and%20content%20types%20should%20live%20within%20the%20root%20site.%20%26nbsp%3BTherefore%20you%20will%20find%20quite%20often%20tthat%20when%20you%20update%20the%20subsite's%20template%20you%20will%20also%20need%20to%20reapply%20the%20root%20site%20as%20columns%2Fcontent%20types%20could%20have%20chnaged.%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-27960%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20PnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27960%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28876%22%20target%3D%22_blank%22%3E%40Vijay%20Rajagopolan%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20agree%20with%26nbsp%3B%40Deleted.%20The%20reason%20why%20you%20would%20need%20to%20keep%20your%20root%20site%20is%20that%20site%20columns%20and%20content%20types%20should%20live%20within%20the%20root%20site.%20%26nbsp%3BTherefore%20you%20will%20find%20quite%20often%20tthat%20when%20you%20update%20the%20subsite's%20template%20you%20will%20also%20need%20to%20reapply%20the%20root%20site%20as%20columns%2Fcontent%20types%20could%20have%20chnaged.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-27934%22%20slang%3D%22en-US%22%3ERE%3A%20PnP%20Provisoning%20to%20include%20Sub%20sites%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-27934%22%20slang%3D%22en-US%22%3EHi%20Vijay%2C%20You%20have%20to%20export%20all%20subsites%20as%20well%20it%20are%20all%20seperate%20templates.%20if%20your%20subsites%20all%20look%20the%20same%20you%20could%20export%201%20subsite.%20You%20need%20to%20use%20at%20least%202%20templates%201%20for%20your%20site%20collection%20and%201%20for%20your%20subsites..%20kr%2C%20Paul%3C%2FLINGO-BODY%3E
Vijay Rajagopolan
New 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
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

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
36 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies