Business Scenario
This is quite usual scenario where developers or site admin have to move newly create list or libraries from Dev environment to Staging / Production. This blog will show options for doing it manually as well as through Powershell. This is series of blog where:
- Save list / library with or without data as list template through powershell.
- Create new list / library using template through powershell
Manual way of saving list as template
After creating and verifying business usability of custom list or library with all custom column etc, if we want to save this list as list template to be used on same farm / environment or other other farms to recreate same list with similar schema or data, we need to follow these steps:
- Open your custom sharepoint list and go to list settings.
- From settings under permission and management section, click save list as template
- Provide template name and file name and choose option if need to save list data along with schema.
- Once list template save it prompts for operation successful page message along with link to list template gallery
Powershell to the rescue
Lets say we need to save multiple list as list templates, so instead of doing it manually we can customize following script:
#Import SharePoint Snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration parameters
$WebURL="http://sharepoint site"
$ListName="List name"
$TemplateName="Template Name"
$TemplateFileName="Template File Name"
$TemplateDescription="Some description"
$SaveData = $false
#Get the Web and List objects
$Web = Get-SPWeb $WebURL
$List = $Web.Lists[$ListName]
#Save List as Template
$List.SaveAsTemplate($TemplateFileName, $TemplateName, $TemplateDescription, $SaveData)
Write-Host "List Saved as Template!
and saved list is available in list template gallery
Read More