How to Copy a List in SharePoint Online?
Requirement: Copy a List in SharePoint Online.
How to Copy a SharePoint Online List?
If you’re working in SharePoint Online, there may be times when you need to duplicate a list. Maybe you want to make a copy of an existing list for testing purposes, or perhaps you need to create multiple lists with similar information. Whatever the reason, duplicating a list is a quick and easy process. This article will show you how to duplicate a list in SharePoint Online. Let’s get started!
The modern SharePoint Online sites provide a nifty way to create a list from existing lists. Here is how to make a copy of a list in SharePoint Online:
- Go to the Microsoft SharePoint site where the source list is located.
- From the Home page, click on the “New” button and then choose “List” in the toolbar at the top of the page. You can also go to the “Site Contents” Page (Click on “Settings” gear >> Choose “Site Contents”), click on the “New” menu, and choose “List”.
- This opens a new list creation page, which provides an option to create a new list from the existing list. “Create a list” page. Click on the “From existing list” button on the page.
- Select the existing custom list to clone and click the “Next” button at the bottom to copy the existing list structure. You can even pick a list from different site collections!
- Provide a name to your new list, and click on “Create” to complete the process.
The new list will be created with all of the same fields as the original list. The above method copies the structure of the list without copying any data from it! How about copying lists between sites with data? BTW, You can use the “Content and Structure” page (/_layouts/15/sitemanager.aspx) to move or copy items to the destination list.
Copy a List or Document Library using PnP PowerShell
Use the Copy-PnPList cmdlet to copy a list or document library in SharePoint Online. This cmdlet copies the fields, views, and settings of the list (But does not copy along the list items in the list!).
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
$SourceListName = "Documents"
$DestinationListName = "Documents Backup"
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Copy the list using PnP powershell
Copy-PnPList -Identity $SourceListName -Title $DestinationListName
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Similarly, to copy a list to another site, use the following PowerShell script with admin privileges:
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
$SourceListName = "Documents"
$DestinationSiteURL = "https://crescent.sharepoint.com/sites/Sales"
$DestinationListName = "Documents Backup"
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Copy list to another site using powershell
Copy-PnPList -Identity $SourceListName -Title $DestinationListName -DestinationWebUrl $DestinationSiteURL
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
SharePoint Online: Copy a List from one site to another using PowerShell
Copying a SharePoint list from one site to another manually can be time-consuming and error-prone. But with PowerShell, it’s easy to automate the process! Let me show you how to use PowerShell to copy a SharePoint list with content from one site to another using the Export-Import list template method.
#Parameters
$SourceSiteURL = "https://crescent.sharepoint.com/sites/Retail"
$TargetSiteURL = "https://crescent.sharepoint.com/sites/Sales"
$ListName= "Projects"
$TemplateFile ="$env:TEMP\Template.xml"
#Connect to the Source Site
Connect-PnPOnline -Url $SourceSiteURL -Interactive
#Create the Template
Get-PnPSiteTemplate -Out $TemplateFile -ListsToExtract $ListName -Handlers Lists
#Get Data from source List
Add-PnPDataRowsToSiteTemplate -Path $TemplateFile -List $ListName
#Connect to destination Site
Connect-PnPOnline -Url $TargetSiteURL -Interactive
#Import the exported list - Apply the Template
Invoke-PnPSiteTemplate -Path $TemplateFile
If your list uses lookup fields, make sure you copy the parent list first. Otherwise, you may encounter the error “Invoke-PnPSiteTemplate: Value does not fall within the expected range”. Also, if you want to copy lists along with version history, permissions, etc., you may consider third-party tools like Sharegate.
Conclusion
Copying a list in SharePoint Online is a straightforward process that can save you time and effort when you need to duplicate a list’s structure and settings. Whether you choose to use the web browser “From existing list” method or copy a list using a PowerShell script, you have the flexibility to customize the copied list according to your requirements.
By following the steps outlined in this blog post, you can easily create a copy of a list in SharePoint Online while preserving its columns, views, and settings. This is particularly useful when you want to create multiple lists with similar configurations or when you need to replicate a list across different sites or site collections.
Here is another post on copying the items in the list with attachments, use: Copy items from one list to another in SharePoint Online using PowerShell
Copy-PnPList doesn’t work with document libraries.
How to copy/move list from one SPO site to another, which has flows integrated?
I just wanted to add that if someone gets an error related to the scope while trying to execute this script, you can add after line 14:
(Get-Content -path $TemplateFile) -replace ‘RootSite’,’Web’ | Set-Content -Path $TemplateFile
Thanks!