3

I have about 15 List templates in the (gallery > List templates) and none of them show up when I run following script:

 $web.ListTemplates | ForEach{ write-host $_.Name }

I think that is the reason I am not able to create list based on a template that is in List Template Gallery.

2

You must use the following method SPSite.GetCustomListTemplates to get the list templates create by end users.

SPSite.GetCustomListTemplates

Returns the collection of custom list templates, which are created by end users, from the specified site.

SPWeb.ListTemplates property

Gets the collection of all list definitions and list templates that are available for creating lists on the website.

To find a specific template you can use for example

$web = Get-SPWeb <url of your web>
$site = $web.Site
$templateName = "<template to find>"
$listTemplate = $site.GetCustomListTemplates($SPWeb) | ? {$_.InternalName -match $templateName }
  • To get all Custom List Templates, skip line 3 & 4 and use $listTemplate = $site.GetCustomListTemplates($web) – CigarDoug Jan 15 '15 at 19:02
1

In order to return the collection of custom List Templates the SPSite.GetCustomListTemplates method is intended.

Prerequisites for custom list templates

SharePoint List must meet the following criteria to move a list by using a list template (source):

  • The list must contain less than 10 megabytes (MB) of list data.
  • You must be a member of a site group with the Manage Lists right on the source site and on the destination site. By default, the Manage Lists right is included in the Web Designer and Administrator site groups.
  • The source site and the destination site must be based on the same site template.

Example:

Assume a scenario where source site and the destination site are be based on the different site template.

Then after uploading list templates (stp files) into List Template gallery
enter image description here

the method SPSite.GetCustomListTemplates will return only list named SharePoint Incidents (Custom List type)

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.