Migrate SharePoint List From 2007 To 2013

Migration can be achieved in four different ways.
  1. Using Power shell Script.
  2. Using Third Party Tool like Sharegate
  3. Using List Template.
  4. Microsoft Access 2013.
In this blog, we will discuss only using power shell script.
  • Open window powershell in source machine.
  • Before running export command please change the WebURL to Source Site URL, ListName is the list which we need to migrate and provide the physical path to save the export file. Export-List -WebUrl "http://vmssharepdev02:7777/" -ListName"ExistingDemo" -Path "D:\ExistingDemoExport" -Overwrite
  • Run the export command in powershell window. When export command is successful following file will find in physical location.



  • Open the file into notepad. i.e. SystemData.xml
  • Change the version and build attributes value in SystemData.xml file according to the new environment.



  • To change the build attribute value open Central Administration on destination site and navigate to Upgrade and Migration->Check product and patch installation status. Copy the highlighted text and replace the build attribute value in SystemData.xml file.
  • Version attribute value will be:

    Sharepoint 2010 : Version="14.0.0.0"
    Sharepoint 2013 : Version="15.0.0.0"
  • After replacing build and attribute value as per above description. Save the SystemData.xml file at same location.
  • Open Window Powershell at destination site and run the export command after amending below line in Import command.
Import-List -WebUrl “http://intranet/sites/sales” -Path ""D:\ExistingDemoExport""
Using Power Shell Script
 
Export Command 
  1. function Export-List  
  2. {  
  3. Param (  
  4. [parameter(Mandatory=$true)][string]$WebUrl,  
  5. [parameter(Mandatory=$true)][string]$ListName,  
  6. [parameter(Mandatory=$true)][string]$Path,  
  7. [parameter(Mandatory=$false)][switch]$ExcludeDependencies,  
  8. [parameter(Mandatory=$false)][switch]$HaltOnWarning,  
  9. [parameter(Mandatory=$false)][switch]$HaltOnNonfatalError,  
  10. [parameter(Mandatory=$false)][switch]$AutoGenerateDataFileName,  
  11. [parameter(Mandatory=$false)][switch]$TestRun,  
  12. [parameter(Mandatory=$false)][string]$IncludeSecurity,  
  13. [parameter(Mandatory=$false)][string]$IncludeVersions,  
  14. [parameter(Mandatory=$false)][int]$FileMaxSize,  
  15. [parameter(Mandatory=$false)][switch]$Overwrite,  
  16. [parameter(Mandatory=$false)][switch]$SuppressLog  
  17. )  
  18. #Load SharePoint 2010 cmdlets  
  19. $ver = $host | select version  
  20. if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}  
  21. Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
  22. #Load assemblies (needed for SharePoint Server 2007)  
  23. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
  24. #Check parameters have the correct values  
  25. if (!$IncludeSecurity)  
  26. {  
  27. $IncludeSecurity = "None"  
  28. }  
  29. else  
  30. {  
  31. if (($IncludeSecurity -ne "All") `  
  32. -and ($IncludeSecurity -ne "WssOnly") `  
  33. -and ($IncludeSecurity -ne "None"))  
  34. {  
  35. Throw "The IncludeSecurity parameter must be set to All, WssOnly or None"  
  36. }  
  37. }  
  38. if (!$IncludeVersions)  
  39. {  
  40. $IncludeVersions = "LastMajor"  
  41. }  
  42. else  
  43. {  
  44. if (($IncludeVersions -ne "All") `  
  45. -and ($IncludeVersions -ne "CurrentVersion") `  
  46. -and ($IncludeVersions -ne "LastMajor") `  
  47. -and ($IncludeVersions -ne "LastMajorAndMinor"))  
  48. {  
  49. Throw "The IncludeVersions parameter must be set to All, CurrentVersion, LastMajorAndMinor or LastMajor"  
  50. }  
  51. }  
  52. if (!$FileMaxSize)  
  53. {  
  54. $FileMaxSize = 0  
  55. }  
  56. $site = New-Object Microsoft.SharePoint.SPSite($WebUrl)  
  57. $web = $site.OpenWeb()  
  58. $list = $web.Lists[$ListName]  
  59. [bool]$FileCompression = $false  
  60. #Set file paths for the export file and logs  
  61. [string]$exportPath = $Path.TrimEnd("\")  
  62. if ($exportPath.EndsWith(".cmp"))  
  63. {  
  64. $FileCompression = $true  
  65. $exportFile = $Path.Replace($Path.Remove($Path.LastIndexOf("\")+1),"")  
  66. $exportPath = $Path.Remove($Path.LastIndexOf("\"))  
  67. }  
  68. $logFilePath = $exportPath + "\exportlog.txt"  
  69. New-Item -Path $logFilePath -Type File -Force | Out-Null  
  70. Write-Host "Export log file created at" $logFilePath  
  71. $exportObject = New-Object Microsoft.SharePoint.Deployment.SPExportObject  
  72. $exportObject.Id = $list.ID  
  73. $exportObject.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::List  
  74. #Create the export settings from the parameters specified  
  75. $exportSettings = New-Object Microsoft.SharePoint.Deployment.SPExportSettings  
  76. $exportSettings.SiteUrl = $site.Url  
  77. $exportSettings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]::ExportAll  
  78. $exportSettings.FileLocation = $exportPath  
  79. $exportSettings.FileCompression = $FileCompression  
  80. if ($FileCompression) { $exportSettings.BaseFileName = $exportFile }  
  81. $exportSettings.ExcludeDependencies = $ExcludeDependencies  
  82. $exportSettings.OverwriteExistingDataFile = $Overwrite  
  83. $exportSettings.IncludeSecurity = $IncludeSecurity  
  84. $exportSettings.IncludeVersions = $IncludeVersions  
  85. $exportSettings.LogFilePath = $logFilePath  
  86. $exportSettings.HaltOnWarning = $HaltOnWarning  
  87. $exportSettings.HaltOnNonfatalError = $HaltOnNonfatalError  
  88. $exportSettings.AutoGenerateDataFileName = $AutoGenerateDataFileName  
  89. $exportSettings.TestRun = $TestRun  
  90. $exportSettings.FileMaxSize = $FileMaxSize  
  91. $exportSettings.ExportObjects.Add($exportObject)  
  92. #Write the export settings to a log file  
  93. Out-File -FilePath $logFilePath -InputObject $exportSettings -Append -Encoding utf8  
  94. #Run the export procedure  
  95. $export = New-Object Microsoft.SharePoint.Deployment.SPExport($exportSettings)  
  96. $export.Run()  
  97. #Load notepad showing the log file  
  98. if (!$SuppressLog) { notepad $logFilePath }  
  99. #Dispose of the web and site objects after use  
  100. $web.Dispose()  
  101. $site.Dispose()  
  102. }  
  103. Export-List -WebUrl "http://vmssharepdev02:7777/" -ListName "Incident" -Path "E:\Gaurav\ForMigration\FromLive\Incident" -Overwrite  
Import Command
  1. function Import-List  
  2. {  
  3. Param (  
  4. [parameter(Mandatory=$true)][string]$WebUrl,  
  5. [parameter(Mandatory=$true)][string]$Path,  
  6. [parameter(Mandatory=$false)][switch]$HaltOnWarning,  
  7. [parameter(Mandatory=$false)][switch]$HaltOnNonfatalError,  
  8. [parameter(Mandatory=$false)][switch]$RetainObjectIdentity,  
  9. [parameter(Mandatory=$false)][string]$IncludeSecurity,  
  10. [parameter(Mandatory=$false)][string]$UpdateVersions,  
  11. [parameter(Mandatory=$false)][switch]$SuppressLog  
  12. )  
  13.  
  14. #Load SharePoint 2010 cmdlets  
  15. Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue  
  16. #Load assemblies (needed for SharePoint Server 2007)  
  17. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
  18.  
  19. #Check parameters have the correct values  
  20. if (!$IncludeSecurity)  
  21. {  
  22. $IncludeSecurity = "None"  
  23. }  
  24. else  
  25. {  
  26. if (($IncludeSecurity -ne "All") `  
  27. -and ($IncludeSecurity -ne "WssOnly") `  
  28. -and ($IncludeSecurity -ne "None"))  
  29. {  
  30. Throw "The IncludeSecurity parameter must be set to All, WssOnly or None"  
  31. }  
  32. }  
  33.   
  34. if (!$UpdateVersions)  
  35. {  
  36. $UpdateVersions = "Overwrite"  
  37. }  
  38. else  
  39. {  
  40. if (($UpdateVersions -ne "Overwrite") `  
  41. -and ($UpdateVersions -ne "Append") `  
  42. -and ($UpdateVersions -ne "Ignore"))  
  43. {  
  44. Throw "The UpdateVersions parameter must be set to Overwrite, Append or Ignore"  
  45. }  
  46. }  
  47.   
  48. $site = New-Object Microsoft.SharePoint.SPSite($WebUrl)  
  49. $web = $site.OpenWeb()  
  50.   
  51. $importSettings = New-Object Microsoft.SharePoint.Deployment.SPImportSettings  
  52.  
  53. #Set file paths for the import file and logs  
  54. $fileName = ""  
  55. if ($Path.EndsWith(".cmp"))  
  56. {  
  57. $fileName = $Path.Replace($Path.Remove($Path.LastIndexOf("\")+1),"")  
  58. $importPath = $Path.Remove($Path.LastIndexOf("\"))  
  59. $importSettings.FileCompression = $true  
  60. $importSettings.BaseFileName = $fileName  
  61. }  
  62. else  
  63. {  
  64. $importPath = $Path.TrimEnd("\")  
  65. $importSettings.FileCompression = $false  
  66. }  
  67.   
  68. $logFilePath = $importPath + "\importlog.txt"  
  69. New-Item -Path $logFilePath -Type File -Force | Out-Null  
  70. Write-Host "Import log file created at" $logFilePath  
  71.  
  72. #Create the import settings from the parameters specified  
  73. Write-Host "Configuring import settings"  
  74. $importSettings.SiteUrl = $site.Url  
  75. $importSettings.WebUrl = $web.Url  
  76. $importSettings.FileLocation = $importPath  
  77. $importSettings.IncludeSecurity = $IncludeSecurity  
  78. $importSettings.UpdateVersions = $UpdateVersions  
  79. $importSettings.LogFilePath = $logFilePath  
  80. $importSettings.HaltOnWarning = $HaltOnWarning  
  81. $importSettings.HaltOnNonfatalError = $HaltOnNonfatalError  
  82. $importSettings.RetainObjectIdentity = $RetainObjectIdentity  
  83. $importSettings.UserInfoDateTime = "ImportAll"  
  84. if (!$SuppressLog) { $importSettings }  
  85.  
  86. #Write the import settings to a log file  
  87. Out-File -FilePath $logFilePath -InputObject $importSettings -Append -Encoding utf8  
  88.  
  89. #Run the import procedure  
  90. Write-Host "Import running, please wait..."  
  91. $import = New-Object Microsoft.SharePoint.Deployment.SPImport($importSettings)  
  92. $import.Run()  
  93. Write-Host "Import from" $Path "complete"  
  94.  
  95. #Load notepad showing the log file  
  96. if (!$SuppressLog) { notepad $logFilePath }  
  97.  
  98. #Dispose of the web and site objects after use  
  99. $web.Dispose()  
  100. $site.Dispose()  
  101. }  
Import-List -WebUrl “http://intranet/sites/sales” -Path "C:\Export\TeamContacts"
Ebook Download
View all
Learn
View all