Sunday, May 24, 2015

Create List from Custom List Template in SharePoint using PowerShell

Requirement: Create a SharePoint list from a custom template using PowerShell

PowerShell script to create a SharePoint list from list template:
Lets create a list using template in SharePoint with PowerShell.

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 using template in sharepoint 2013
    $web.Lists.Add($ListName, $ListName, $Template)
    Write-host "New List Created from Custom 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
This script creates list from template (.stp) in SharePoint.
create custom list from template sharepoint



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:

1 comment :

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...