Get Internal Name of a Column in SharePoint Online using PowerShell

Requirement: Get the internal name of a SharePoint Online list column using PowerShell.

How to Get the Internal Field Name in SharePoint Online?

As explained in my other post: SharePoint Field Display Name vs. Internal Name, When you create a new column in SharePoint, You give a “Title” to it, which becomes the “Display Name”. SharePoint automatically assigns the internal name from the display name by replacing all special characters and spaces with Unicode encoding. A field can have the same internal name or a different name from its display name (E.g., the “Created by” field’s internal name is: Author!). And this internal name stays static – even if you change the field’s title. At times, You may need the internal name of a column to retrieve field values in SharePoint.

Here is how to find the internal name of a field in the SharePoint Online list:

  1. Navigate to the List or Document Library >> Click on Settings >> List Settings.
  2. Under the Column section, click on any of the columns, and you can get the column internal name in the URL from the Field parameter value. E.g. In my case, it’s: “Project_x0020_Classification”sharepoint online get column internal name


You can also sort the column and get the internal name from the SortField parameter value.

sharepoint online powershell get internal field name
Is it possible to change column internal name in SharePoint Online? The answer is: NO! You can’t change the internal name of a field in SharePoint. The only workaround is: Delete and Recreate the column.

SharePoint Online: PowerShell to Get Internal Field Name

If you need to reference the column in your code or other scripts, this handy PowerShell script helps you get the column’s internal name. Let’s get the field’s internal name from its display name in SharePoint Online:

#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/PMO"
$ListName ="Projects"
$FieldTitle = "Project Classification"

#Get Credentials to connect
$Cred= Get-Credential

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
         
#Get the List and field
$List = $Ctx.Web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
$Field =  $List.Fields.GetByTitle($FieldTitle)
$Ctx.Load($Field)
$Ctx.ExecuteQuery()

         
#PowerShell to get internal name of sharepoint online list column
Write-Host $Field.InternalName
It’s a good idea to create a column without space or special character initially, So that the field internal name will be neat and clean, and then change the field’s title with any special characters or space if required!

SharePoint Online: PnP PowerShell to Get Internal Field Name

This time, let’s use PnP PowerShell to get the internal field name of all fields from a SharePoint Online list.

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/PMO"
$ListName ="Projects"
$FieldTitle = "Project Classification"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the list column
Get-PnPField -Identity $FieldTitle -List $ListName | Select InternalName

How about getting the internal names of all fields in a list?

#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/PMO"
$ListName ="Projects"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
    
    #Get list column internal names
    Get-PnPField -List $ListName
}
Catch {
    Write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

To get all fields from the SharePoint Online list, use: SharePoint Online: Get All List Fields using PowerShell

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!

Leave a Reply

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