SharePoint Online: Rename a Column in List using PowerShell

When we create a new list or library in SharePoint Online, the “Title” column gets created automatically. SharePoint doesn’t allow us to delete this title column. However, we can change the “title” column name to something relevant, such as “Project Name” in the “Projects” list.

How to Rename a List Column in SharePoint Online?

Have you ever needed to rename a column in a SharePoint Online list? Maybe the column’s name doesn’t fit the data that’s being stored, or you want to make it more user-friendly for people who will be using the list. In this blog post, we’ll walk you through the steps to rename a field in a SharePoint Online list. We’ll also show you how to use PowerShell to rename a column in a SharePoint Online list.

Here is how to rename a List column in SharePoint Online:

  1. Navigate to your target SharePoint Online list >> Go to the List settings page.
  2. Pick any column, such as “Title” from the “Columns” section. You’ll get the Edit Column page.
  3. Now you can rename the field at “Column Name” and hit the “OK” button to save your changes.
    powershell to rename column in sharepoint online

Rename a Field in SharePoint Online Modern Experience:

Renaming columns in the Modern User interface is much simpler than the classic. Here is how to change the name of a field in modern UI:

  1. Mouse over the field name and click on the little drop-down menu to get its context menu.
  2. In the context menu, choose “Column settings” >> and then “Edit”.rename a column in sharepoint online
  3. In the “Edit column” pane, Set the “Name” field for the column and hit the “Save” button on the bottom to save your changes.how to rename a column in sharepoint online

What if you don’t find the “Edit” option in Column Settings?

The edit option may not be available for all columns. So, how to rename columns such as ID, Attachments, etc.? Well, here is the trick!

  1. Navigate to your list or library settings page.
  2. Click on any available column to get into column settings. E.g., the “Title” column. The URL should look like this: https://YourDomain.sharepoint.com/sites/YourSite/_layouts/15/FldEdit.aspx?List=ListGUID&Field=Title. Now, replace the “Field” parameter in this URL with the field you want to rename. Say: “Attachments” column: https://Crescent.sharepoint.com/sites/Retail/_layouts/15/FldEdit.aspx?List=%7B8791A814%2D94A7%2D42AF%2DB0BF%2D8CD8037B554F%7D&Field=Attachments
  3. Enter the new name for the attachments column and hit OK.

Here is the renamed attachment column in action:

rename attachment column in sharepoint

PowerShell to Rename SharePoint Online List Column:

Here is the PowerShell to change the field title in SharePoint Online.

#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 Rename-ListColumn()
{
  param
    (
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ListName,
        [Parameter(Mandatory=$true)] [string] $ColumnName,
        [Parameter(Mandatory=$true)] [String[]] $NewName
    )

    Try {
        $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)
        $Ctx.Load($List)
        $Ctx.ExecuteQuery()

        #Get the column to rename
        $Field = $List.Fields.GetByInternalNameOrTitle($ColumnName)
        $Field.Title = $NewName
        $Field.Update()
        $Ctx.ExecuteQuery()
            
        Write-Host "Column Name Changed successfully!" -ForegroundColor Green

    }
    Catch {
        write-host -f Red "Error Renaming Column!" $_.Exception.Message
    } 
}

#Parameters
$SiteURL="https://crescent.sharepoint.com"
$ListName="Projects"
$ColumnName="Titles"
$NewName="Project Title"

#Call the function to rename column
Rename-ListColumn -SiteURL $SiteURL -ListName $ListName -ColumnName $ColumnName -NewName $NewName

PnP PowerShell to Update Field Title and Description in SharePoint Online:

Let’s look at how to use PnP PowerShell to rename a column in a SharePoint Online list. You can change the name of a column in a list using the Set-PnPField cmdlet.

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"
$ListName = "Team Projects"
$FieldName= "ProjectStatus" #Internal Name

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
    
    #Set Field Title and Description
    Set-PnPField -List $ListName -Identity $FieldName -Values @{Title="Status";Description="Status of the Project"} -ErrorAction Stop
    Write-host -f Green "Title and Description Updated for Field '$FieldName'"
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

Please note, You can’t rename the name column in the SharePoint Document library with any of these methods! Renaming columns from SharePoint UI and programmatically using PowerShell and C# is explained in other articles:

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “SharePoint Online: Rename a Column in List using PowerShell

  • How to rename column ‘Attachment’ in List share point, before I can do easier just choose rename but right now this button it’s gone.

    Reply
    • Use the URL trick in this article! E.g. https://YourDomain.sharepoint.com/sites/YourSite/_layouts/15/FldEdit.aspx?List=ListGUID&Field=Attachments

      Reply

Leave a Reply

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