Copying a List on SharePoint Online
Referance: https://www.yunusemrearac.com/2024/05/22/sharepoint-online-uzerinde-liste-kopyalama/
Hello friends, today I will tell you how you can copy one of your lists in the Sharepoint online environment.
The first of these methods is to perform this operation using the Sharepoint interface and the user who will perform this operation must be an authorized user.
First, we go to the “Site Contents” section of the sharepoint site where we will copy. We click on the “List” option in the menu that appears by pressing the “+ New” button on the top left.
Here, we select the “From existing list” option from the options in the popup that opens on the screen.
Again, in the newly opened screen, select the site from which you will copy the list from the Sharepoint sites under the “Select a Team or site” heading on the left, and find and select the list you will copy from the lists on that site on the right, and proceed with the “Next” button.
Then, in the new popup, the list you copied will be filled with the name and description section. After giving the name and definitions to your new list, we can create our list by pressing the “Create” button.
As you can see, we created a copy of our list via the sharepoint interface without using any code or anything extra.
Apart from this method, we can also copy the list using the PnP Powershell code.
$SiteURL = "https://yunusenrearac.sharepoint.com/"
$SourceListName = "yunus emre araç"
$DestinationListName = "yunus emre araç 2"
Try {
Connect-PnPOnline -Url $SiteURL -Interactive
Copy-PnPList -Identity $SourceListName -Title $DestinationListName
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Using the above powershell code, you can run the script and perform your operation after defining the parameters suitable for your own site and lists.
$SiteURL = "https://yunusemrearac.sharepoint.com/sites/site1"
$SourceListName = "yunus emre araç"
$DestinationSiteURL = "https://yunusemrearac.sharepoint.com/sites/site2"
$DestinationListName = "yunus emre araç 2"
Try {
Connect-PnPOnline -Url $SiteURL -Interactive
Copy-PnPList -Identity $SourceListName -Title $DestinationListName -DestinationWebUrl $DestinationSiteURL
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
If the sites you will copy from are different, you can use the above powershell script.
$SourceSiteURL = "https://yunusemrearac.sharepoint.com/sites/site1"
$TargetSiteURL = "https://yunusemrearac.sharepoint.com/sites/site2"
$ListName= "yunus emre araç"
$TemplateFile ="$env:TEMP\Template.xml"
Connect-PnPOnline -Url $SourceSiteURL -Interactive
Get-PnPSiteTemplate -Out $TemplateFile -ListsToExtract $ListName -Handlers Lists
Add-PnPDataRowsToSiteTemplate -Path $TemplateFile -List $ListName
Connect-PnPOnline -Url $TargetSiteURL -Interactive
Invoke-PnPSiteTemplate -Path $TemplateFile
Another method is to copy the template structure of the list and use it to copy the list.
As you can see, you can create your friends lists in many different ways.