SharePoint Online: Delete a Column from List using PowerShell

Requirement: Delete a column from a SharePoint Online list.

How to remove a column from SharePoint Online List?

In SharePoint Online, you can delete a column from a list when it is no longer needed. In this article, we will show you how to delete a column from a SharePoint list. Deleted columns are permanently removed and can’t be restored. Remember that any data in the column will also be deleted. Let’s get started!

We can delete Columns from lists or libraries when they are no longer needed. To delete a list column, follow these steps:

  1. Navigate to the list where the column that you want to delete is located
  2. Click on Settings Gear and choose “List Settings” (In Classic experience: Go to List tab >> Under Settings group, click on the List Settings button in the ribbon).
    how to delete a column in a sharepoint online list
  3. Under the List Settings page, in the Columns section, click on the column title you wish to delete.
  4. Scroll down and click on the Delete button.
    sharepoint online list delete column
  5. Confirm the deletion prompt by clicking OK.

This deletes the SharePoint Online list column. The changes will take effect immediately. You can verify that it has been deleted by refreshing the list page and checking that the column is no longer listed. You can also go back to the list settings and check the columns list to confirm that the column has been deleted.

Please note, When you delete a column in SharePoint, all the data saved in the column is also deleted! We can’t restore this column data from recycle bin!

SharePoint Online List: How to Delete a Column in Modern Experience?

To delete a column in a modern list, do the following:

  1. Navigate to the list or library from which you want to delete a column.
  2. Click on the column header for that you want to delete >> Select Column settings >> Edit
    sharepoint online list how to delete column
  3. Click on “Delete” button at the bottom of the Edit Column pane.
    how to delete a column in a sharepoint online list

SharePoint Online: Delete List Column using PowerShell

Here is the PowerShell to delete a column from a List 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"
  
#Variables for Processing
$SiteURL="https://crescent.sharepoint.com"
$ListName= "Projects"
$ColumnName="Project Code" #Display Name of the column

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)

    #Get the Column to delete
    $Column = $List.Fields.GetByTitle($ColumnName)
    
    #sharepoint online delete list column powershell
    $Column.DeleteObject()
    $Ctx.ExecuteQuery()

    Write-host "Column '$ColumnName' deleted Successfully!" -ForegroundColor Green
 }
Catch {
    write-host -f Red "Error Deleting Column from List!" $_.Exception.Message
}

PnP PowerShell to Remove a Column from SharePoint Online List:

Here is how to remove a column from a list using the PnP PowerShell cmdlet Remove-PnPField in SharePoint Online.

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

#Get Credentials to connect
$Cred = Get-Credential

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
    
    #sharepoint online powershell delete list column
    Remove-PnPField -Identity $ColumnName -List $ListName -Force -ErrorAction Stop
    Write-host "Column '$ColumnName' Removed from the List Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

Is the delete Button missing in Column Settings? Getting an “Operation is not valid due to the current state of the object” Error when trying to delete the field using PowerShell? Attempts to set the “Sealed” Property also failed? Well, For now, I don’t find any other ways to delete a sealed column other than hiding it from the list! How to hide a column from SharePoint Online List?

If you want to remove a site column from SharePoint Online, use: SharePoint Online: Delete Column using PowerShell

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!

6 thoughts on “SharePoint Online: Delete a Column from List using PowerShell

  • Anyway to delete a field from a list when it exceeded the 5000 threshold limit?

    Reply
  • Wish there was some direction on how to delete multiple columns! This was great though – thank you

    Reply
    • Just place them in an Array and use the Remove-PnPField. E.g.

      $ColumnNames  = @("Projects", "Department", "Vertical")
      
      ForEach($Column in $ColumnNames)
      {
          Remove-PnPField -Identity $Column -List $ListName -Force -ErrorAction Stop
          Write-host "Column '$Column' Removed from the List Successfully!" -f Green
      }
      
      Reply
  • Great Help! The only thing I found out for “sealed” columns is to add these additional lines to the Column Section and the Update Command:
    #Get the Column to delete
    $Column = $List.Fields.GetByTitle($ColumnName)
    $Column.Hidden = $false
    $Column.ReadOnlyField = $false
    $Column.Sealed = $false
    $Column.Update()
    $Column.DeleteObject()
    $Ctx.ExecuteQuery()

    Reply
    • I’ve no luck setting the “Sealed” Property to $False. Tried even updating schema, but it didn’t work!

      Reply
  • This is exactly what I have been searching for!

    Reply

Leave a Reply

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