Creating a site collection for each web template

Summary: This blog post provides a PowerShell script that creates a site collection for each SharePoint WebTemplate available.

I found that after years of consulting, I still didn’t know all the web templates SharePoint has to offer, so I decided to create a PowerShell script that creates a site collection for each web template.

It creates the site collections under the “/sites/” wildcard inclusion Managed Path.

#Update variables here
$templates = get-spwebtemplate
$webappURL = "https://yoururl.domain.com"
$SCAdmin = "domain\username"

#-- don't change anything below this line --#

foreach($template in $templates)
{
$templatename = $template.name -replace "#",""
$url = $($webappURL) + "/sites/" + $($templatename)
New-SPSite -URL $url -Language 1033 -Template $template.name -Name $($template.name) -OwnerAlias $SCAdmin
}

After running the script, check out the sites at your URL /sites/templatename (minus the #).

webtemplate-example

Leave a Reply

Your email address will not be published. Required fields are marked *