How to Save List as a Template using PowerShell in SharePoint?
Requirement: Save SharePoint list as a template using PowerShell
How to Save List as template in SharePoint?
List templates in SharePoint provides great re-usability without having to recreate every single columns. Say for e.g. you may have created a custom list (say: Projects) in a SharePoint site collection with all relevant columns, Now you might want this list structure in other site collections, without recreating the list on every single site. To save a list or library as template:
PowerShell Script to save list as a template:
Here is how to save list as template in SharePoint 2013 using PowerShell.
Now, You can create a new list instance from the template saved: Create List from List Template in SharePoint using PowerShell
If you need to save a SharePoint Online List as template, use: SharePoint Online: PowerShell to Save List as Template
How to Save List as template in SharePoint?
List templates in SharePoint provides great re-usability without having to recreate every single columns. Say for e.g. you may have created a custom list (say: Projects) in a SharePoint site collection with all relevant columns, Now you might want this list structure in other site collections, without recreating the list on every single site. To save a list or library as template:
- Go to your SharePoint list >> Navigate to list settings by going to List tab on the ribbon and then List Settings.
- Click on "Save list as Template" under Permissions and Management group.
- Provide the name for template File and Template name
- Choose the appropriate option for "include content" and Click OK.
Generally, it's a good idea to create list templates at top-level site, so that any site underneath can utilize the template!
PowerShell Script to save list as a template:
Here is how to save list as template in SharePoint 2013 using PowerShell.
#Add SharePoint Snapin Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration parameters $WebURL="https://projects.crescent.com" $ListName="Parent Projects" $TemplateName="Parent Project Template" $TemplateFileName="ParentProjectTemplate" $TemplateDescription="Crescent Inc. Parent Project List Template" $SaveData = $true #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!"
Now, You can create a new list instance from the template saved: Create List from List Template in SharePoint using PowerShell
If you need to save a SharePoint Online List as template, use: SharePoint Online: PowerShell to Save List as Template
Can you save template from a .csv and overwrite the existing template?
ReplyDeleteWorked well!
ReplyDeleteIs it possible this changes using Javascript or PNP JS?
ReplyDeleteThank you so much !!! awesome blog this is what i wanted...
ReplyDelete