How to Migrate a Single List From SharePoint 2007 to 2010 Using PowerShell

In this article I am showing how to migrate a single list from SharePoint 2007 to SharePoint 2010.

The basic steps are:

  1. Run a shell script to export a list to a DAT file.
  2. Change this DAT file to CAB, and extract this file so that you can access SystemData.xml in the CAB file, and modify the version information there.
  3. Remake the CAB file and change the extension to .CMP.
  4. Use PowerShell in SharePoint 2010 to import the list from the .CMP file.

Step 1

Open Windows PowerShell in 2007 server and paste in the following script to export a list to a folder in 2007 server:

function Import-List([string]$DestWebURL, [string]$FileName, [string]$LogFilePath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Deployment") > $null
$settings = New-Object Microsoft.SharePoint.Deployment.SPImportSettings
$settings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::All
$settings.UpdateVersions = [Microsoft.SharePoint.Deployment.SPUpdateVersions]::Overwrite
$settings.UserInfoDateTime = [Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption]::ImportAll
$site = new-object Microsoft.SharePoint.SPSite($DestWebURL)
Write-Host "DestWebURL", $DestWebURL
$web = $site.OpenWeb()
Write-Host "SPWeb", $web.Url
$settings.SiteUrl = $web.Url
$settings.WebUrl = $web.Url
$settings.FileLocation = "C:\ListExport\"
$settings.BaseFileName = $FileName
$settings.LogFilePath = $LogFilePath
$settings.FileCompression = 1

Write-Host "FileLocation", $settings.FileLocation
$import = New-Object Microsoft.SharePoint.Deployment.SPImport($settings)
$import.Run()
$web.Dispose()
$site.Dispose()
}
# For Export a specified SharePoint List
Export-List " Your List Url /"
ListURL "Your List Url /"

After you have run this shell script you will have your export list in the 2007 server in "C:\ListExport\".

Step 2

Next, what we need to do is change this DAT file to a CAB.

Extract the file so that you can access SystemData.xml in the CAB file, and modify the version information there.

Open the SystemData.xml file in a text editor, and change Version="12.0.0.0" to Version="14.0.0.0", and Build="12.0.0.6514" to Build="14.0.0.1000".

Step 3

Copy all files that come in the CAB folder along with the modified SystemData.xml file to "C:\Program Files\Microsoft Visual Studio 9.0\VC"; see:

modified-SystemData-xml-file.jpg

Open a Visual Studio command prompt and paste in the command:

makecab.exe /f makecab.ddf

As shown below:

Open-Visual-studio-command-prompt.jpg

A ListSt.CAB file is created as shown below in Screen shot. A Sample DDF file is also shown below:

Sample-DDF-file.jpg

Now open the ListSt.CAB folder and import in 2010.

Step 4

Copy the cab file to the 2010 server.

We can use PowerShell on a SharePoint 2010 server and run the Import-spweb to import the list.

PS C:\> Import-SPWeb -Identity "http://trvustcvdw0110:11254/" -Path "E:\Rogin\E
xportNewlist.cmp" –IncludeUserSecurity

Now the list is ready in the 2010 site as shown below:

list-is-ready-in-2010.jpg