Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create SP Sites based on Term Store
$web = get-spweb http://sp2013/sites/Root #Change to your site URL
$template = $web.GetAvailableWebTemplates(1033) | Where-Object {$_.Title -eq “TemplateSite”} #Change to your template name
$SiteCollection = Get-SPSite http://sp2013/sites/Root #Change to your site URL
#Get the Term Store ID
$TaxSession = Get-SPTaxonomySession -Site $SiteCollection
$TermStore = $TaxSession.TermStores[“Managed Metadata Service”] #Change to your service name
#Get the Term Set
$TermStoreGroup = $TermStore.Groups[“Functions”] #Change to your Terms Store group name -the main parent term
$TermSetList = $TermStoreGroup.TermSets
#create an array
$myArray = $TermSetList.Terms
foreach ($element in $myArray)
write-host $ -ForegroundColor Magenta #writes the term
$NewSiteUrl = $web + "/" + $
write-host $NewSiteUrl -ForegroundColor green #writes the new sites url
#check if it already exists
$exists = Get-SPWeb -Identity $NewSiteUrl -ErrorAction SilentlyContinue | Select-Object -Property Exists -ErrorAction SilentlyContinue
if($exists -eq $null)
#create the new site
$newweb = New-SPWeb -Url $NewSiteUrl -Name $ -AddToTopNav -UseParentTopNav
#apply your template
write-host "Created" -ForegroundColor green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment