Saturday, January 25, 2014

How to Upload a List Template in SharePoint 2013 using PowerShell

Requirement: Upload a custom list template to specific site collections in a web application. While upload a list template using from SharePoint web interface is simple, wanted to automate this process as its repeating for multiple site collections.

PowerShell to Upload list template in SharePoint 2013:
Here is the PowerShell script to upload custom list template to SharePoint site :

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

Function Upload-ListTemplate($WebURL, $TemplateFilePath)
 #Get the Web
 $web = Get-SPWeb $WebURL
 #Get the List template Gallery Folder
 $TemplateFolder = $web.GetFolder("List Template Gallery") 
 #Get the Files collection
 $TemplateFileCollection = $TemplateFolder.Files
 #Get the Template file from Local File system
 $TemplateFile = Get-ChildItem $TemplateFilePath
 #Open the File in Read mode and Add to Templates collection 
    $TemplateFileCollection.Add("_catalogs/lt/$($TemplateFile.Name)", $TemplateFile.OpenRead(), $true)
 Write-Host "Done!Template has been uploaded!!"

 #Call the function to upload list template
 Upload-ListTemplate "" "D:\Templates\CreditTemplate.stp"
You can verify the uploaded template by navigating to List template gallery:
how to upload list template in sharepoint 2010 using powershell

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...