Using PowerShell on a SharePoint 2010 site, how can you create a new list from a list template found in the list template gallery?. I want to be able to add several lists at once (just in numerically ascending order). What I have is:

$web = "http://site"
Get-SPWeb $web | ForEach { foreach ($hotdesk in 1,2,3) { $_.Lists.Add("Hot Desk " + $hotdesk, "",
$_.ListTemplates["My List Template"])}}

However, 'My List Template' doesn't work, since it looks like it only uses the built in list templates, not any custom ones that have been created from an existing list or uploaded to the site.


you can get the built in list templates using the SPListTemplateType enumeration:

$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::Contacts

if you want to access custom list templates saved as STP files on your site, you have to fetch them from your sites list templates and access them through the list name:

$site = Get-SPSite http://site
$listTemplates = $site.GetCustomListTemplates($web)
$web.Lists.Add("Your new list", "", $listTemplates["ListTemplateName"])

you can also save these list templates using SaveAsTemplate() method on a given SPList object.

  • That seems to work, although you only get to see list templates when the account you are running the script as is in the owners group of the site (I ran it as a regular contributor and GetCustomListTemplates returned nothing) – Sam Mar 10 '11 at 10:42
  • a contributor shouldnt be able to create lists anyhow. That permission are pr default granted to Designers – Anders Rask Mar 11 '11 at 11:26
  • If a list template is gotten in this way, then we have the reference, but how do we confirm that it is right? How could I write-host and get a confirmation? – bgmCoder Nov 21 '12 at 18:10
  • 1
    i dont understand your question – Anders Rask Nov 21 '12 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.