Home » SharePoint Online » How to Migrate SharePoint List to Another Site? A Step-By-Step Approach
SharePoint Online ~ 7 Minutes Reading

How to Migrate SharePoint List to Another Site? A Step-By-Step Approach

author
Published By Aldrich Calvin
Anuraag Singh
Approved By Anuraag Singh
Calendar
Published On June 7th, 2024

Overview: SharePoint list is used to store multiple information in the table format. Here you will find how to migrate SharePoint list to another site. There are different ways to move SharePoint list to another site. All the methods are discussed in detail.

The SharePoint list has the crucial data. But due to some of the situations such as mergers, changing tenants, and many more, you need to transfer SharePoint list to another site. The whole process of list transfer to another site is performed by the administrator because Office 365 Admins have different roles and responsibilities.

Different Methods to Move SharePoint List to Another Site

There are different methods through which you can move a list from one SharePoint site to another site. The first one is the template method in which you need to download and upload the list template.

The second method is performed with the help of PowerShell and the last one is the professional solution. Let’s explore each one in detail.

Migrate SharePoint List to Another Site Using the Template method

In this method, you need to create a template of the source SharePoint site for the successful migration. Then you can migrate that template to the destination. Follow the below steps.

Step 1. Save List as Template

  • Open and log in to the SharePoint.
  • Click on the List settings icon.
  • Now go to the Permissions and Management section.
  • Save the list as a template option.

Step 2. Copy of the Template

  • Go to the collection of sites.
  • Click on the Site Settings icon.
  • Now Galleries >> and List template.
  • Tick the checkbox next to the template needed to export.
  • Now hit on the Download copy button.

Step 3. Export Template to Destination Site

  • Go to the destination site with the .stp file.
  • Click on the Site Settings & Galleries.
  • Click on the List template and then the Documents tab.
  • Now hit on the Upload Document option and browse the file.
  • Click OK and the process is completed.

How PowerShell Helps to Move SharePoint List to Another Site?

You can also use the PowerShell to move the SharePoint list to another site. But you should be good enough to handle all the complicated PSH commands. Because of some difficult commands, it is not advised to use.

But, if you want to move forward with the PSH commands then, you need to create lists on both sites with the same rows and columns. Execute the PowerShell as administrator.

If the list is not having any attachments then run,

Install-Module -Name PnP.PowerShell
#Connect to the Source Site
Connect-PnPOnline -Url https://[entertenantname].sharepoint.com/sites/[name of source site] -Interactive
#Create the Template
Get-PnPSiteTemplate -Out C:\Temp\Lists.xml -ListsToExtract “List A”, “List B” -Handlers Lists
Get the List Data
Add-PnPDataRowsToSiteTemplate -Path C:\Temp\Lists.xml -List “List A”
Add-PnPDataRowsToSiteTemplate -Path C:\Temp\Lists.xml -List “List B”
#Connect to Target Site
Connect-PnPOnline -Url https://[entertenantname].sharepoint.com/sites/[name of destination site] -Interactive
#Apply the Template
Invoke-PnPSiteTemplate -Path “C:\Temp\Lists.xml”

If the list items contain attachments then,

#Function to copy attachments between list items
Function Copy-SPOAttachments()
{
param
(
[Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.ListItem] $SourceItem,
[Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.ListItem] $DestinationItem
)
Try {
#Get All Attachments from Source list items
$Attachments = Get-PnPProperty -ClientObject $SourceItem -Property “AttachmentFiles”
$Attachments | ForEach-Object {
#Download the Attachment to Temp
$File = Get-PnPFile -Connection $SourceConn -Url $_.ServerRelativeUrl -FileName $_.FileName -Path $Env:TEMP -AsFile -force
#Add Attachment to Destination List Item
$FileStream = New-Object IO.FileStream(($Env:TEMP+”\”+$_.FileName),[System.IO.FileMode]::Open)
$AttachmentInfo = New-Object -TypeName Microsoft.SharePoint.Client.AttachmentCreationInformation
$AttachmentInfo.FileName = $_.FileName
$AttachmentInfo.ContentStream = $FileStream
$AttachFile = $DestinationItem.AttachmentFiles.Add($AttachmentInfo)
Invoke-PnPQuery -Connection $DestinationConn
#Delete the Temporary File
Remove-Item -Path $Env:TEMP\$($_.FileName) -Force
}
}
Catch {
write-host -f Red “Error Copying Attachments:” $_.Exception.Message
}
}
#Function to copy list items from one list to another
Function Copy-SPOListItems()
{
param
(
[Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.List] $SourceList,
[Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.List] $DestinationList
)
Try {
#Get All Items from the Source List in batches
Write-Progress -Activity “Reading Source…” -Status “Getting Items from Source List. Please wait…”
$SourceListItems = Get-PnPListItem -List $SourceList -PageSize 500 -Connection $SourceConn
$SourceListItemsCount= $SourceListItems.count
Write-host “Total Number of Items Found:”$SourceListItemsCount
#Get fields to Update from the Source List – Skip Read only, hidden fields, content type and attachments
$SourceListFields = Get-PnPField -List $SourceList -Connection $SourceConn | Where { (-Not ($_.ReadOnlyField)) -and (-Not ($_.Hidden)) -and ($_.InternalName -ne “ContentType”) -and ($_.InternalName -ne “Attachments”) }
#Loop through each item in the source and Get column values, add them to Destination
[int]$Counter = 1
ForEach($SourceItem in $SourceListItems)
{
$ItemValue = @{}
#Map each field from source list to Destination list
Foreach($SourceField in $SourceListFields)
{
#Check if the Field value is not Null
If($SourceItem[$SourceField.InternalName] -ne $Null)
{
#Handle Special Fields
$FieldType = $SourceField.TypeAsString
If($FieldType -eq “User” -or $FieldType -eq “UserMulti”) #People Picker Field
{
$PeoplePickerValues = $SourceItem[$SourceField.InternalName] | ForEach-Object { $_.Email}
$ItemValue.add($SourceField.InternalName,$PeoplePickerValues)
}
ElseIf($FieldType -eq “Lookup” -or $FieldType -eq “LookupMulti”) # Lookup Field
{
$LookupIDs = $SourceItem[$SourceField.InternalName] | ForEach-Object { $_.LookupID.ToString()}
$ItemValue.add($SourceField.InternalName,$LookupIDs)
}
ElseIf($FieldType -eq “URL”) #Hyperlink
{
$URL = $SourceItem[$SourceField.InternalName].URL
$Description = $SourceItem[$SourceField.InternalName].Description
$ItemValue.add($SourceField.InternalName,”$URL, $Description”)
}
ElseIf($FieldType -eq “TaxonomyFieldType” -or $FieldType -eq “TaxonomyFieldTypeMulti”) #MMS
{
$TermGUIDs = $SourceItem[$SourceField.InternalName] | ForEach-Object { $_.TermGuid.ToString()}
$ItemValue.add($SourceField.InternalName,$TermGUIDs)
}
Else
{
#Get Source Field Value and add to Hashtable
$ItemValue.add($SourceField.InternalName,$SourceItem[$SourceField.InternalName])
}
}
}
#Copy Created by, Modified by, Created, Modified Metadata values
$ItemValue.add(“Created”, $SourceItem[“Created”]);
$ItemValue.add(“Modified”, $SourceItem[“Modified”]);
$ItemValue.add(“Author”, $SourceItem[“Author”].Email);
$ItemValue.add(“Editor”, $SourceItem[“Editor”].Email);
Write-Progress -Activity “Copying List Items:” -Status “Copying Item ID ‘$($SourceItem.Id)’ from Source List ($($Counter) of $($SourceListItemsCount))” -PercentComplete (($Counter / $SourceListItemsCount) * 100)
#Copy column value from Source to Destination
$NewItem = Add-PnPListItem -List $DestinationList -Values $ItemValue
#Copy Attachments
Copy-SPOAttachments -SourceItem $SourceItem -DestinationItem $NewItem
Write-Host “Copied Item ID from Source to Destination List:$($SourceItem.Id) ($($Counter) of $($SourceListItemsCount))”
$Counter++
}
}
Catch {
Write-host -f Red “Error:” $_.Exception.Message
}
}
#Set Parameters
$SourceSiteURL = “https://[tenantnamehere].sharepoint.com/sites/[sitenamehere]”
$SourceListName = “[listnamehere]”
$DestinationSiteURL = “https://[tenantnamehere].sharepoint.com/sites/[sitenamehere]”
$DestinationListName = “[listnamehere]”
#Connect to Source and destination sites
$SourceConn = Connect-PnPOnline -Url $SourceSiteURL -Interactive -ReturnConnection
$SourceList = Get-PnPList -Identity $SourceListName -Connection $SourceConn
$DestinationConn = Connect-PnPOnline -Url $DestinationSiteURL -Interactive -ReturnConnection
$DestinationList = Get-PnPList -Identity $DestinationListName -Connection $DestinationConn
#Call the Function to Copy List Items between Lists
Copy-SPOListItems -SourceList $SourceList -DestinationList $DestinationList

Drawbacks of PowerShell and Template Method

Both the manual solutions have some drawbacks due to which these methods are not advised to use. Some of the key drawbacks are.

  • Suitable for Small Migrations Only – The template method is only applicable for the small size of sites. If the template size is bigger than 50 MB, then it will not work.
  • Data Loss – By using the PowerShell commands there is a huge risk of data loss. All the commands should be properly executed, if any of the commands is not followed in the order then the data will be affected.
  • Complexities – The manual methods are complicated and need to be executed with the focused. Misjudging or skipping any step does not give the expected results.
  • Lack of Advanced Features – In the manual methods, no advanced feature is there such as filtering out data and others.

Conclusion

In this write-up, we have discussed all the methods to migrate SharePoint list to another site. If you are good at technicalities and confident enough to execute the manual methods then you can go with the manual methods with the SharePoint Online migration checklist. Otherwise, the professional solution is the best one for the list migration from One SharePoint site to another.

Frequently Asked Questions

Q. What’s the process for transferring a SharePoint list to a different location?

To transfer a SharePoint list to a different location, you can utilize the “Save as Template” option to export the list as a template file. Following that, you can then generate a new list from that template in the new location.

Q. Do you need to be aware of any restrictions or factors when transferring a SharePoint list to a different location?

Yes, there are certain restrictions to keep in mind. If the source and target sites differ in their functionalities or settings, certain adjustments or settings might not work as expected. Additionally, ensure you possess the required access rights to export and import list templates or carry out the transfer of data.

Q. How can I verify that my list was successfully migrated?

After migration, check the destination site to ensure all items, columns, and settings match the source list.