Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to script the creation of data in SharePoint, and part of this requires that I upload a slide library list template using PowerShell. Is this possible?

share|improve this question

3 Answers 3

You can cheat using Webdav :

Copy-Item 'yourTemplate.stp' '\\yourspwebapp\DavWWWRoot\sites\yoursitecoll\_catalogs\lt'

[edit] according your comment, here is a way to find the correct url.

  1. Navigate using the browser to the list template catalog list. The link should look like : http://yourwebapp/sites/yoursitecoll/_catalogs/lt
  2. as it is a document library, you can, from the ribbon's tab "Library", click on Open in windows explorer
  3. an windows explorer windows pop ups, but with "http://" address.
  4. Right click in the window, click properties, and you will find the actual address.

This worked for me, with a SP application having a custom AAM (yourspwebapp is not the hostname, but a virtual hostname). I checked locally... did you want to do this remotely ?

[Edit2] if installing Webdav is an issue on your server, you can use the following snippet :

$wc = new-object System.Net.WebClient
$file = (Get-Item '.\New Text Document.txt')
$dest = "http://yourspwebapp/sites/yoursitecoll/_catalogs/lt"
$wc.UseDefaultCredentials = $true
$wc.UploadFile($dest +"/" + $file.Name, $file.FullName)

Or you can use the sp OM, as Jimmarq suggests

share|improve this answer
Hmm. I'm getting WebDav errors. I can't even map a drive to My Site. I must have a problem doing this from a 2008 R2 box. – jimmarq Jun 28 '11 at 13:28
I'm also running on a 2008 R2 box – Steve B Jun 28 '11 at 13:38
When I click "Open with Exporer" I get an error message saying "Your client does not support opening this list with Windows Explorer." I'm guessing I'm missing either office components, or the Desktop Experience feature. – jimmarq Jun 28 '11 at 13:47
so this is another issue. Maybe this can help :… or… – Steve B Jun 28 '11 at 13:49

WebDav might work for others, but I found a way to do it using the SharePoint object model. (I used the folders indicated by Steve B--thanks.)

$site = get-spsite "http://myteam.lab/sites/team"
$web = $site.OpenWeb()
$spFolder = $web.getfolder("List Template Gallery")
$spfilecollection = $spfolder.files
$file = get-item c:\temp\MyTemplate.stp
$spfilecollection.Add("_catalogs/lt/MyTemplate.stp", $file.OpenRead(), $true)

I saw the template in the "Create" page, so everything seemed to work ok.

share|improve this answer

To add to this, if you would like to add the list template to all of your site collections, use this instead...

$GetSiteCollections = Get-SPSite -Limit ALL
## Add the List Template to the all the Site Collections
foreach($GetSiteCollection in $GetSiteCollections)
$web = $GetSiteCollection.OpenWeb();
$spfolder = $web.getfolder("_catalogs\lt")
$spfileCollection = $spfolder.Files
$file = Get-Item c:\Templates\MyListTemplate.stp
$spfileCollection.Add("MyListTemplate.stp", $file.OpenRead(), $true)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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