PoshCode Archive  Artifact [fd669647a3]

Artifact fd669647a380935656aef91b35c2c87c0f0a860a13b3f6591ba7f827fa38c040:

  • File createSiteFromTemplate.ps1 — part of check-in [046f32d9a7] at 2018-06-10 13:28:22 on branch trunk — createSiteFromTemplate.ps1 (user: brodobrey size: 1693)

# encoding: ascii
# api: powershell
# title: createSiteFromTemplate
# description: createSiteFromTemplate.ps1
# version: 0.1
# author: brodobrey
# license: CC0
# x-poshcode-id: 3630
# x-archived: 2012-09-15T04:00:19
# x-published: 2012-09-07T06:38:00
#
#
# Load the template
$url = "http://spf" # where template base
$namesite = "Good Site" #name new site title
$targeturl = "goodsite" #name url new site
# find id = viewAlltemplate
$templateID = "{055CF2A7-43A8-48E1-95CB-19DC393F0215}"
#$templateID = "{055CF2A7-43A8-48E1-95CB-19DC393F0215}#kolam"

$site= new-Object Microsoft.SharePoint.SPSite($url ) 
# 1049 - russian, 1033 -english
$loc= [System.Int32]::Parse(1049) 

# have list template with Russian localization
$templates= $site.GetWebTemplates($loc) 

#Write-Host "templates = " $templates

# view all templates in table - 
# this for find id custom template for installing
foreach ($child in $templates){    write-host $child.Name "  " $child.Title} 
# Теоретически - высвобождает ресурсы
$site.Dispose() 

#look in the Output for the right one, and copy the Template Name

#create a new-SPWeb
$web = New-SPWeb -Url http://spf/$targeturl -Name "$namesite" -UseParentTopNav -AddToTopNav -UniquePermissions

#-Template ""{E6BD7EFF-8336-4975-BA22-2256970781E2}#SubWebTemplate"


# Another option is to create the New-SPWeb without the
#-template argument. Then you can apply the custom template 
# by following line:
$web.ApplyWebTemplate($templateID)