SharePoint Online: PowerShell to Rename a List

Requirement: SharePoint Online PowerShell to Rename a List

How to Rename List in SharePoint Online?

When you create a list in Microsoft SharePoint Online, the name is automatically generated based on the list’s title. In some cases, you may want to rename the list. This article will show you how to rename a list in SharePoint Online using both the Classic and Modern user interfaces. We will also show you how to rename a list in SharePoint Online using PowerShell.

To change the list name in SharePoint Online, follow these steps:

  • Navigate to your SharePoint Online list or library. Click on Settings Icon and then “List Settings” (In Classic UI, Under “List” tab, Click on “List Settings” button from the ribbon)
  • In the List settings page, Click on “List name, description and navigation” link under “General Settings” heading.
  • In General Settings page, You can update the Title of the list and click on “Save” to commit your changes.
    sharepoint online powershell rename list

This changes the name of a list or document library in SharePoint Online.

PowerShell to Rename a List in SharePoint Online

Now let’s walk you through the process of renaming a SharePoint Online list using PowerShell. This can be helpful if you have a long or difficult-to-remember list name or if you want to rename a list as part of an automation process. Here is the PowerShell script to change the name of a SharePoint Online List:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Function to Rename a SharePoint Online List or library using PowerShell
Function Rename-SPOList
{
    param
    (
        [string]$SiteURL  = $(throw "Please Enter the Site URL!"),
        [string]$ListName = $(throw "Please Enter the List Name to Rename!"),
        [string]$NewName = $(throw "Please Enter the New Name for the List!")
    )
    Try {
        #Get Credentials to connect
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials

        #Get the List
        $List=$Ctx.Web.Lists.GetByTitle($ListName) 

        $List.Title = $NewName
        $List.Update()
        $Ctx.ExecuteQuery()
            
        Write-Host "List has been Renamed to '$NewName' Successfully!" -ForegroundColor Green  
    }
    Catch {
        write-host -f Red "Error Renaming List!" $_.Exception.Message
    }
}
 
#Call the function to rename a list or library
Rename-SPOList -SiteURL "https://Crescent.sharepoint.com/" -ListName "Documents" -NewName "Team Documents"

This script quickly and easily renames your list without touching the user interface. Please note, changing the list title doesn’t change the list URL! If you need to change the URL of a SharePoint Online list, refer to How to Change the List URL in SharePoint Online using PowerShell?

You can also rename a document library in SharePoint Online with this PowerShell script!

SharePoint Online: Change List Name using PnP PowerShell

If you need to rename a list in SharePoint Online with just a few lines of code, PnP PowerShell is the way to go! Here is how to change the name of a document library in SharePoint Online with PnP PowerShell:

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Rename "Projects" List to "Projects Archive"
Set-PnPList -Identity "Projects" -Title "Projects Archive"

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “SharePoint Online: PowerShell to Rename a List

  • Is there a way renaming multiple lists using a csv file

    Reply
  • I have renamed SharePoint List Name by going to List Settings and from there Name and Description and renamed the list. However, some users see the old SharePoint List Name. This also happened with the Top menu bar which I solved the problem after deleting and creating the same menu bar item again. The list has plenty of items recorded so I can not just delete and create the same list again. Do you know what could cause the problem ?

    Reply

Leave a Reply