Sunday, May 24, 2015

Create List from List Template in SharePoint using PowerShell

Requirement: Create a SharePoint list from List template using PowerShell

PowerShell script to create a SharePoint list from list template:
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

Function Create-ListFromTemplate($WebURL, $ListName, $TemplateName)
{
    #Get the Web from URL
    $Web = Get-SPWeb $WebURL

    #Get the Specific list template
    $Template = $web.site.GetCustomListTemplates($Web) | where {$_.InternalName -match $TemplateName }

 #Check if given template name exists!
    if($Template -eq $null)
    {
        Write-host "Specified list template not found!" -f Red
        exit
    }

    #Create List instance from given list template
    $web.Lists.Add($ListName, $ListName, $Template)
    Write-host "List instance Created from List template" -f DarkGreen 
}

#Variables
$WebURL="http://intranet.crescent.com"
$ListName="Project-607"
$ListTemplateName="ProjectTemplate"

#Call the function to create list from template
Create-ListFromTemplate $WebURL $ListName $ListTemplateName



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


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...