While working through an upgrade issue, we had a need to move about 14 Discussion Boards to a subweb. We initially went the old school route of saving the lists as a template, including the content, then creating lists using the templates. The content came across, but the Created By fields were showing the user that created the list from the template.
I then remembered that in SharePoint 2010, you can export and import lists. There is UI in Central Admin to export a list, but there is no UI to import the list. With 14 lists, manually exporting/importing the lists wasn’t real appealing, but a bit of research turned up the following PowerShell cmdlets: Export-SPWeb and Import-SPWeb.
With the PowerShell cmdlets, I put together the following PowerShell script that takes in a comma-delimited set of List Titles, and copies them to another web. The key part to getting the Created By and Modified By info to come across with the list is the –IncludeUserSecurity switch with the cmdlets.
1: #This is the source web that is hosting the lists to move
2: $sourceWebUrl = "http://server.SharePoint.Com/Sub1"
4: #This is the destination web, where the lists will be copied to
5: $destWebUrl = "http://server.SharePoint.com/Sub1/forums"
7: #Location to store the export file
8: $path = "\\Server\Share\"
10: #comma delimited list of List Names to copy
11: $lists = @("List Number 1", "List Number 2")
14: #Loop through the lists, export the list from the source, and import the list into the destination
15: foreach($list in $lists)
17: "Exporting " + $sourceWebUrl + "/lists/" + $list
19: export-spweb $sourceWebUrl -ItemUrl ("lists/" + $list) -IncludeUserSecurity -IncludeVersions All -path ($path + $list + ".cmp") -nologfile
21: "Exporting complete."
25: "Importing " + $destWebUrl + "/lists/" + $list
27: import-spweb $destWebUrl -IncludeUserSecurity -path ($path + $list + ".cmp") -nologfile
29: "Importing Complete"
good information the way of written was appriciated
nice PowerShell snippet. thanks for sharing.
Excellent walk through.
November 2013 - Still helping, thanks for posting this.