I want to set the "Hidden" attribute for a listtemplate to hide it from the create list dialog. I need a solution where I can switch visibility of listtemplates on a per web basis. First I tried this:

$web.ListTemplates["Project Document Library"].Hidden = $true

Unfortunately the "Hidden" attribute is readonly. According to MSDN the attribute is defined in the SchemaXml attribute of the listtemplate. So I tried this:

$template=$web.ListTemplates["Project Document Library"]
$schema.ListTemplate.SetAttribute("Hidden", "TRUE")

Found out that SchemaXml is readonly as well.

Thank you for every hint about how to hide listtemplates...

Regards, Friedrich


The suggestion above, although acheiving the desired effect will need to be done on all servers in the farm and is unlikely to survive an upgrade / patch. It's not therefore generally a good idea to do this.

Using PowerShell - If you grab the ID of the list template feature

$myWeb = (Get-SPSite "http://MySite").OpenWeb()
$featureToDisable = Get-SPFeature -Web $myWeb | ?{$_.DisplayName -eq "DocumentLibrary"}

Check that you have only one element in $featureToDisable. Now, you will have the Identity of the list feature that although installed at farm level has a scope of Web. This can now be disabled ...

$featureToDisable | Disable-SPFeature -Url $myWeb.Url

If you want it to be enabled, then you will have to get a reference to the feature at the farm level and then pipe this to the Enable-SPFeature commandlet with similar parameters. e.g.

$featureToEnable = Get-SPFeature | ?{$_.DisplayName -eq "DocumentLibrary"}
$featureToEnable | Enable-SPFeature -Url $myWeb.Url
|improve this answer|||||
  • I am going to delete my answer as yours is far superior for the reasons you mention. You might want to update the first few lines of your post. – Robert Kaucher Apr 24 '13 at 17:34
  • I'm curious to know if disabling the 'DocumentLibrary' feature could have any surprise consequences. I'm also curious to know what Robert Kaucher's deleted answer was, as it might still have provided some valuable insight even if it is supposedly an inferior answer. – Dennis George Oct 23 '13 at 21:59

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.