Create a site using an existing template with Powershell

  …this post was published on 2016 July 5.

starting from this post, let’s try to script few lines to create a site from an existing template.
First , you should launch Sharepoint Powershell Modele in your environment

Add-PSSnapin microsoft.sharepoint.powershell

For an existing site, get available WebTemplates

$site = get-SPWeb http://sp2013:81
$template = $site.GetAvailableWebTemplates(1033)

From these templates, I will use only WiKis, so​

$template = $site.GetAvailableWebTemplates(1033) | Where-Object { $_.Name -match “WIKI#0”}
$template

Name                 Title                                    LocaleId   CompatibilityLevel   Custom   
—-                 —–                                    ——–   ——————   ——   
WIKI#0               Wiki Site                                1033       15                   False    
ENTERWIKI#0          Enterprise Wiki                          1033       15                   False    
and because are 2 sites, I will use the first one –  and what I need is the name
$template[0].Name
WIKI#0
Last step is to create the new site, using this last command
New-SPWeb -Url “http://sp2013:81/testXa” -Name “testX” -Template $template[0].Name
This entry was posted in Powershell, Sharepoint. Bookmark the permalink.