1

Trying to create a list template from custom list using Powershell in SharePoint online and trying to download the template on my local machine.

How to create list template achieve above requirement

Updates in question :- How to create list template using client side object model in PowerShell? suggest links..

2 Answers 2

0
$site = get-spsite("http://testsite")
$web = $site.RootWeb
$list = $web.Lists["Announcements"]
SharePoint $list.SaveAsTemplate() PowerShell Command use following parameters.
$list.SaveAsTemplate(“Template Name”,”Template Title”,”Template Description”,1)

In the forth parameter of SaveAsTemplate(), if you want to save the specified site as template along with data use 1, otherwise use 0.

Eg:- $list.SaveAsTemplate("TestListTemplate.stp", "TestListTemplate", "Test List Template", $false)

Source : Creating a List template from a list with PowerShell

4
  • is above script work for SharePoint online ? Nov 23, 2015 at 13:08
  • you need to try it out, this is actually for 2010 Nov 23, 2015 at 13:09
  • 1
    yes i have try this script , not working for SharePoint online Nov 23, 2015 at 13:13
  • 1
    can we save list template using csom , if yes please suggest some links Nov 23, 2015 at 13:14
0

Based on myknowledge, it’s not feasible to export lists and libraries in SharePoint Online using PowerShell.

For detailed information about the cmdlets for SharePoint Online, please see:

Introduction to the SharePoint Online Management Shell.

Basically using CSOM you can create lists using already existing custom templates, but programmatically you cannot create new ones as SaveAsTemplate method is not exposed in CSOM API.

To create a list from existing custom template below is the code.

ClientContext context = new ClientContext("http://SiteUrl");
var web = context.Web;
context.Load(web,s => s.ListTemplates );
context.ExecuteQuery();
var listCreationInfo = new ListCreationInformation
{
Title = "My Jobs",
Description = "This is the job list description"
};
var listTemplate = site.ListTemplates.First(template => template.Name == "Jobs");
listCreationInfo.TemplateFeatureId = listTemplate.FeatureId;
listCreationInfo.TemplateType = listTemplate.ListTemplateTypeKind;
site.Lists.Add(listCreationInfo);
context.ExecuteQuery();
4
  • yes , you are right.. so please suggest some CSOM in powershell links, Nov 23, 2015 at 13:54
  • please see my updated answer
    – Amit Kotha
    Nov 23, 2015 at 16:02
  • Amit thanks for above code, give me links where i can see code for create list template using list in SharePoint online using CSOM in PowerShell Nov 24, 2015 at 5:48
  • 1
    as u sated that "SaveAsTemplate method is not exposed in CSOM API.",so please give me some articles, for your statements.... Nov 24, 2015 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.