Friday, December 5, 2014

How to list template upload list template gallery in powershell Scripts

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$listtemplate=("Doc_Template 1.stp","Doc_Template 1.stp","Doc_Template 2.stp","")
$site = get-spsite("http://yoursite/")

$web = $site.RootWeb

$spLTG = $web.getfolder("List Template Gallery")

$spcollection = $spLTG.files

ForEach($template in $listtemplate) {
$Templatefile = get-childitem "C:\Raghu\" $template
Write-Host  $Templatefile

$spcollection.Add("_catalogs/lt/"+$template, $Templatefile.OpenRead(), $true)
Write-Host "Custom Template Uploaded to List Template Gallery Successfully"

Write-Host "Creating the List based on the Template"

$CustomlistTemplates = $site.GetCustomListTemplates($web)
}

No comments:

Post a Comment