SharePoint Online: Change List Field Settings using PowerShell

Requirement: Update SharePoint Online List Field Settings using PowerShell.

How to Edit Column Settings in SharePoint Online?

Properties of the list field, such as display name, type, or other related column settings, can be updated through the list settings page. To change column settings in a list or library, follow these steps:

  1. Navigate to the SharePoint Online list or library where you want to edit a column.
  2. Go to the list or library settings page from Ribbon or the Site Settings menu >> Under the Columns section, pick the column to update.
  3. On the Edit Column page, You can make any necessary changes and click on the OK button to Save.
    SharePoint Online update List Field Settings using PowerShell

Please note that changing column type is limited to specific columns based on the current column type. Furthermore, you may lose data when switching between column types. E.g., When you switch from Multiple lines of text to a Single line of text, It’s limited to 255 characters.

PowerShell to Change Field Settings in SharePoint Online List

We can also change field settings for a list in SharePoint Online using PowerShell. This can be useful if you need to make changes to a field’s properties, such as the display name, required flag, default value, etc.

#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"

#Set Config Parameters
$FieldName="HeadCount" #Internal Name

#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

#Get the List Field

#Set List Field Settings
$Field.Title= "Total Resources"
$Field.Description = "Number of Resources working on the Project"

#set default value
$Field.DefaultValue = "10"

$Field.EnforceUniqueValues = $False

#set field hidden
$Field.Hidden = $False

#set field required
$Field.Required = $True
$Field.FieldTypeKind = "Text"
$Field.Indexed = $False

#set field read only
#$Field.ReadOnlyField = $True

#Apply changes

Write-host "Field Settings Updated!"

PnP PowerShell to Update Field Properties in SharePoint Online List

Here is how to automate changing the field settings for a SharePoint Online list using PnP PowerShell:

#Config Variables
$SiteURL = ""
$ListName = "Team Projects"
$FieldName = "ProjectStatus" #Internal Name

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
    #Set Field Properties
    Set-PnPField -List $ListName -Identity $FieldName -Values @{Required=$True;DefaultValue="Active"}    
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red

Similarly, you can set any other property of the list field, such as “Title” or “Description” as:

-Values @{Title="Name of the Column";Description="Updated List Description"}  

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!

One thought on “SharePoint Online: Change List Field Settings using PowerShell

  • How to change FieldType, eg from single line of text to multiple lines?


Leave a Reply

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