As I've asked in the title, I have a SiteCollectionA which contains SiteTemplateA. Now I want to create a SiteCollectionB from SiteTemplateA.

Can I do that by C# code, or Powershell, or something else ?


You can create the new Site Collection without selecting a Template by choosing Select Template Later option.

Once the new site collection is ready. Navigate to the Site Collection this will prompt you to select the template. Here you have option to upload custom template and use it.

You can automate this using below PowerShell scripts

New-SPSite http://newsitecollectionurl -OwnerAlias OwnerName  -Name "Name of site collection"
Add-SPUserSolution -LiteralPath Path_To_WSP_Template_File -Site http://newsitecollectionurl
#Wait till above command is finished

Install-SPUserSolution -Identity TemplateWSPName.wsp -Site http://newsitecollectionurl

#Now we need to find the Web Template ID ... You can use below loop to find it out

$site= new-Object Microsoft.SharePoint.SPSite(http://newsitecollectionurl)
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates)
    write-host $child.Name "" $child.Title

#Now Apply the template

$web = GET-SPWeb $mainurl

How to create root site collection with custom web template using PoweShell

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.