Upload list template from computer to list template gallery using Power Shell in SharePoint

Upload list template from computer to list template gallery using Power Shell in SharePoint

Upload list template from computer to list template gallery using Power Shell in SharePoint. In my previous post, I discussed how to Save list as template (.stp) using PowerShell. In this post, we will see how to upload list template to a list template gallery from the computer.The below commands will describe how to Upload list template from computer to list template gallery.

[AdSense-A]

Add-PSSnapin Microsoft.SharePoint.Powershell
Function UploadListTemplate($SPWebURL, $TemplateFilePathName)
{
#Get the SPWeb
$SPweb = Get-SPWeb $SPWebURL
#Get the List template Gallery Folder
$TemplateFolderName = $SPweb.GetFolder("List Template Gallery")
#Get the Files collection
$TemplateFileCollection = $TemplateFolderName.Files

$TemplateFileName = Get-ChildItem $TemplateFilePathName

#Open the File in Read mode and Add to Templates collection
$TemplateFileCollection.Add("_catalogs/lt/$($TemplateFileName.Name)", $TemplateFileName.OpenRead(), $true)
Write-Host "Template uploaded!!"
}
 #Call function
 UploadListTemplate "http://site" "C:\Template\Test_Tem.stp"

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!