0

Hello good day.

I am trying to copy a list of type "Issue Tracking" to a list that has the same properties and structure. Until now, I have not been able to do it, since the option "Save as Template with content" is disabled by the modern view (I tried the classic view, but it is not possible either). I tried to do the copying process using Power Automate, but it won't let me do it as the list has exceeded 5000 records.

Could you give me an idea of how to make that copy of the list?

Thank you in advance.

1 Answer 1

0

Please run the below PowerShell script as an administratorin the SharePoint Online Management Shell

Add-Type –Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" 
Add-Type –Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" 

$siteURL = "https://tenant.sharepoint.com/sites/echo" 

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL) 

$userId = "[email protected]" 

$pwd = Read-Host -Prompt "Enter password" -AsSecureString  

$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)  

$ctx.credentials = $creds  

#Enter List Name
$list1 = $ctx.Web.Lists.GetByTitle("Issue Tracking")  

$list2 = $ctx.Web.Lists.GetByTitle("Issue Tracking B")  

$list1Items = $list1.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())  

$fields = $list1.Fields  

$ctx.Load($list1Items)  

$ctx.Load($list1)  

$ctx.Load($list2)  

$ctx.Load($fields)  

$ctx.ExecuteQuery()  

foreach($item in $list1Items)
{      
    Write-Host $item. ID     

    $listItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation      

    $list2Item = $list2.AddItem($listItemInfo)       

    foreach($field in $fields) 
    {          
        #Write-Host $field.InternalName " - " $field.ReadOnlyField   

        if((-Not ($field.ReadOnlyField)) -and (-Not ($field.Hidden)) -and ($field.InternalName -ne  "Attachments") -and ($field.InternalName -ne  "ContentType"))
        {              

            Write-Host $field.InternalName " - " $item[$field.InternalName]              

            $list2Item[$field.InternalName] = $item[$field.InternalName]              

            $list2Item.update()          

        }      
    }  
}  

$ctx.ExecuteQuery()  

enter image description here

enter image description here

List1: Issue Tracking

enter image description here

List2: Issue Tracking B

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.