Save list as list template from powershell

7.2k Views Asked by At

I can't find powershell command to save list instance as list template (to stp file) or export to stp file?

2

There are 2 best solutions below

0
Jason Weber On BEST ANSWER

Calling SPList.SaveAsTemplate via PowerShell should do the trick.

0
Navin saini On

Saving your list as Template

$site = get-spsite("<YourSite>")
$web = $site.RootWeb

$list = $web.Lists["<Your List>"]
$list.SaveAsTemplate(“Template Name”,”Template Title”,”Template Description”,1)

4th Parameter above -> if you want to save the specified site as template along with data use 1, otherwise use 0.

Creating a new list from the template created.

$listTemplates = $site.GetCustomListTemplates($web)
$web.Lists.Add("<List Name>", "<List Desc>",$listTemplates["<Template List Name>"])