I want to create new SPWebs with a Custom Template.
$web = New-SPWeb $Url
$web.ApplyWebTemplate("{GUID}#MyCustomTemplate")
My problem is now that the creation from one SPWeb with the Custom Templat开发者_JS百科e takes about 40 s on my VM. Is there a other and faster way to create SPWebs with a Custom Template?
Why not use -template parameter. For example,
New-SPWeb -url $url -template "{GUID}#MyCustomTemplate"
I did not have a custom template to use but this took 2 seconds on my system.
@LaPhi, you'll get an exception when your custom WebTemplate is not yet activated on your Site (Collection).
I, too, cannot get "New-SPWeb $Url -template "TemplateName" to provision with the Template. You'll likely need to wait until the site is provisioned.
My Solution: First create the new Web:
$web = New-SPWeb $UrlFull
After this, apply the Web template
$web.ApplyWebTemplate("{GUID}#NameCustomTemplate")
The reason is, that the Custom Template is not global.
You have to use this syntax
New-SPWeb -url $url -template "MyCustomTemplateName#0"
You can find these values in Configuration tag of your webtemp_*.xml
<Configuration ID="0" Title="MyCustomTemplateName" ...
精彩评论