Search This Blog

Thursday, March 21, 2013

Export a list using Powershell

Well this post is more for a syntax reference.

Using Export-SPWeb is one of the ways copy list schema and data from one web app to another Or one server to another.

Onw of the reasons I have used this many times is for a list that is in production - copy that list only to a Dev environment to work and develop artifacts for that list like workflow, event handlers etc.

Here is the sample that explains the syntax:

Export-SPWeb -Identity "http://str-sp2010/subsite" -ItemUrl "/subsite/lists/List Title here"
-path "c:\folder\filename.dat"


-Identity: full url (absolute) of the site where the list exists
-ItemUrl:  relative path of the list from subsite level. Do not forget to include the leading "/"
-path: path of the output file to save the data in. This does not need any extension but I usually give it .dat meaning data

There are lot more additional parameters but above are the minimum for copying a list

To recreate the list in other environment - we use Import-SPWeb command.