How to Copy a SharePoint List using PowerShell?

Requirement: Copy a SharePoint List to Another List.

How to copy a list in SharePoint?

Do you need to make a copy of a SharePoint list? Maybe you want to back up the data in the list or create a new list with the same set of columns and settings as an existing one! In any case, using PowerShell is the quickest and easiest way to do it. This article will show you how to copy a SharePoint list using PowerShell.

While Export-Import is an option, You can save the list with or without content as a template and create any number of new lists or libraries from the list template. Go to the list settings, save the list as a template, and then create a new list and pick the list template!

sharepoint copy list

PowerShell to Clone a List in SharePoint

Here is the PowerShell to copy the SharePoint list structure using the “Save List as Template” and “Create List from Template” methods:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Parameters
$SiteURL="https://intranet.crescent.com"
$ListName="Projects"
$NewListName = "Projects Archive"
$SaveData= $False

Try {
    #Get the web and List
    $Web = Get-SPWeb $SiteURL
    $List = $Web.Lists[$ListName]

    #Check if the new list doesn't exists
    If($Web.Lists.TryGetList($NewListName) -eq $null)
    {
        #Save list as template
        $List.SaveAsTemplate($List.ID.ToString(), $List.ID.ToString(), [string]::Empty, $SaveData)

        #Get the List template
        $ListTemplate = $web.Site.GetCustomListTemplates($web)[$List.ID.ToString()]

        #Clone list
        $NewList = $web.Lists.Add($NewListName, "$($NewListName)-$($List.Description)", $ListTemplate)

        #Remove the List template file Created
        $ListTemplateFile = $web.Site.RootWeb.GetFolder("_catalogs/lt").Files | where {$_.Name -eq $ListTemplate.InternalName}
        $ListTemplateFile.Delete()

        write-host -f Green "List '$ListName' Cloned to '$NewListName!'"
    }
    Else
    {
        write-host -f Yellow "List '$NewListName' already exists!"
    }

}
Catch {
    write-host -f Red "Error Adding Template to Document Library!" $_.Exception.Message
} 

You can use this script to duplicate the SharePoint list with content or just list structure. You can set the $SaveData flag to $True to include the list’s contents. To copy a list in SharePoint Online: How to copy a list in SharePoint Online?

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

4 thoughts on “How to Copy a SharePoint List using PowerShell?

Leave a Reply

Your email address will not be published. Required fields are marked *