Powershell Week – Day 1: Copy List Structure Using Template

This week I’m starting a series of posts with several Powershell scripts I’ve been writing to help with some activities that might take a long time if you do it manually. I hope you enjoy the Powershell scripts as I do!

This first one is about creating a list or document library based on an existing one. The approach used is to save the existing library as a template and then creating the new one based on the template.

$site = get-spsite("http://www.yourwebapplication.com")
$web = $site.Allwebs["your web site"]
$list = $web.Lists["your library"]
$list.SaveAsTemplate("TemplateName.stp", "TemplateName", "Template Name", $false)
# the last parameter defines wheter you want the data to be saved in the template

$listTemplates = $site.GetCustomListTemplates($web)
$web.Lists.Add("New List URL", "New list Name", $listTemplates["TemplateName"])

If you want, you can also delete the template after the copy is created.

See you,



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: