Wednesday, May 1, 2013

Upload a List Template (.STP) File to the List Template Gallery in SharePoint 2010 using PowerShell

I recently needed to upload some custom list templates that were created in SharePoint to other environments, up from development and into UAT and Production.  Of course adding new list templates to the gallery is easy, just navigate to the gallery and upload them!  But I wanted to write some PowerShell so these could be scripted.  I needed a little search engine help to remember the exact PowerShell commands and lo and behold there wasn't a single post about this topic.  So here it is, the PowerShell needed to upload a list template to the List Template Gallery:

$web = Get-SPWeb http://yoururl
$spFolder = $web.GetFolder("List Template Gallery")
$spFileCollection = $spFolder.Files
$file = Get-ChildItem "C:\yourawesomelisttemplate.stp"
$spFileCollection.Add("_catalogs/lt/yourawesomelisttemplate.stp", $file.OpenRead(), $true)


1 comment:

  1. Your post help to save my time, thank you very much