How can I copy a sharepoint list in the same sharepoint environment with powershell. I use the powershell modules "pnppowershell" or "SharepointOnline.CSOM".

Greetings, P

1 Answer 1


Using Invoke-PnPSiteTemplate you can copy/import list in SharePoint.

Refer the powershell.

[void] MoveSpoList() {
        # looping through the lists
        $csvInput = Import-Csv -Path '.\Lists.csv'
        foreach ($row in $csvInput) {
            try {

                # Connects SharePoint Online
                Connect-PnPOnline -Url $this.SourceUrl.Trim() -Interactive

                $ListName = $row.ListName.Trim();
                $IsLookUpList = $row.IsLookUpList.Trim();
                Write-Host $ListName
                Write-Host $IsLookUpList

                #Getting List Template Name
                $timestamp = Get-Date -Format FileDateTimeUniversal
                $tempFile = './SourceListBackup/' + $ListName + $timestamp + '.xml';

                Get-PnPSiteTemplate -Handlers Lists -ListsToExtract $ListName -Out $tempFile

                #Adding Rows to List Template
                if ($IsLookUpList -eq 1) {
                    Add-PnPDataRowsToSiteTemplate -Path $tempFile -List $ListName -Query '<View></View>'

                #Applying Template to Destination Site
                Connect-PnPOnline -Url $this.DestinationUrl.Trim() -Interactive
                Invoke-PnPSiteTemplate -Path $tempFile
            } catch {
                Write-Host -ForegroundColor Red 'Error ', ':', $Error[0].ToString();
                Start-Sleep 10

I have explained in details in below article and code is available to download.

Move SPO List

Your Answer

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

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