Forum Discussion
RJF61
Jan 18, 2023Copper Contributor
Copy SharePoint List and Data
I have a SharePoint List where I am making some updates to columns, etc. Is there a way to copy ALL data from one list to another? I have duplicated the list structure but now need to copy informat...
SvenSieverding
Jan 19, 2023Bronze Contributor
Hi RJF61 ,
that more complicated powershell script that copies the values of every source item including created and modified would look like this
Connect-PnPOnline https://tenant.sharepoint.com/sites/SourceSite -Interactive
$itemData= Get-PnPListItem -List "SourceListName"
Connect-PnPOnline https://tenant.sharepoint.com/sites/TargetSite -Interactive
$itemData| foreach-object {
Add-PnPListItem -List "TargetListName" -Values @{
"Title"=$_.FieldValues.Title;
"YourOtherColumn"=$_.FieldValues.YourOtherColumn;
.....
Created=$_.FieldValues.Created;
Modified=$_.FieldValues.Modified;
Author=$_.FieldValues.Author.Email;
Editor=$_.FieldValues.Editor.Email;
}
}You have to enter the rest of your columns in line 11 and following
Best Regards,
Sven