Share via


Create a SharePoint site using an existing template with Powershell

starting from this post, let's try to script few lines to create a site from an existing template. This script is this one

Add-PSSnapin microsoft.sharepoint.powershell
$site = get-SPWeb http://sp2013:81
$template = $site.GetAvailableWebTemplates(1033)
$template = $site.GetAvailableWebTemplates(1033) | Where-Object { $_.Name -match "WIKI#0"}
$template
#and because are 2 results , I will use the first one -  and what i need is the name for it
#Name                 Title                                    LocaleId   CompatibilityLevel   Custom    
#----                 -----                                    --------   ------------------   ------    
#WIKI#0               Wiki Site                                1033       15                   False     
#ENTERWIKI#0          Enterprise Wiki                          1033       15                   False     
$template[0].Name
New-SPWeb -Url "http://sp2013:81/testXa" -Name "testX" -Template $template[0].Name

**
**This post, can be found on my blog as well