SharePoint Server: How to Remove a Column from a List using PowerShell?

Problem: The user created a calculated column with an error in its formula, which caused the list view web part to crash. Therefore, the user couldn’t remove the column from the SharePoint list using the web UI.

How to delete a Column from the SharePoint List?

Do you need to delete a column in a SharePoint list? PowerShell makes it easy. In this article, we’ll walk you through the process of deleting a column from a SharePoint list and show you how to use PowerShell to remove a column from your SharePoint list.

From SharePoint Web UI, to remove a field from a list or library, follow these steps:

  1. Browse to the List or Library in which you want to remove the column. Click on the List or Library tab.
  2. Click on List Settings / Library Settings from the Ribbon. 
  3. From the List Settings page, Under the Columns section, click on the name of the column that you wish to delete.
    How to Remove a Column from SharePoint List using PowerShell
  4. Scroll down to the bottom and then click on the “Delete” button. Confirm the prompt.

PowerShell script to delete the column from the SharePoint list

If you need to remove a column from a SharePoint list, but the web browser UI didn’t help, then PowerShell is the way to go! Here is the PowerShell to remove a column from the list:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Variables
$SiteURL="https://intranet.crescent.com/" 
$ListName="Change Request"
$ColumnName="Activity Status"

#Get Internal Name of the columns
$web = Get-SPWeb $SiteURL

#Get the list
$list = $web.Lists.TryGetList($ListName)

if($List -ne $null)
{
    #Get the column 
    $column = $list.Fields[$ColumnName]

    if($column -ne $null)
    {
        #Reset column properties to allow delete
        $column.Hidden = $false
        $column.ReadOnlyField = $false
        $column.AllowDeletion = $true
        $column.Update()

        #delete column in sharepoint list
        $list.Fields.Delete($column)
        write-host "Column has been deleted!" -f Green
    }
    else
     {
        write-host "Specified column name not found!" -ForegroundColor Red
     }
}

Bulk remove columns from the SharePoint list using PowerShell:

Let’s wrap the code inside a function and call to bulk delete columns from the SharePoint list to make it reusable. 

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Custom Function to delete a column with PowerShell
Function Remove-Column($WebURL, $ListName, $ColumnName)
{

    #Get Internal Name of the columns
    $web = Get-SPWeb $WebURL

    #Get the list
    $list = $web.Lists.TryGetList($ListName)

    if($List -ne $null)
    {
        #Get the column 
        $column = $list.Fields[$ColumnName]

        if($column -ne $null)
        {
            #Reset column properties to allow delete
            $column.Hidden = $false
            $column.ReadOnlyField = $false
            $column.AllowDeletion = $true
            $column.Update()

            #Delete the column from list
            $list.Fields.Delete($column)
            write-host "Column '$ColumnName' has been deleted!" -f Green
        }
        else
        {
            write-host "Specified column name not found!" -ForegroundColor Red
        }
    }
    else
    {
        write-host "Specified List is not found!" -ForegroundColor Red
    }
}

#Variables
$WebURL="https://intranet.crescent.com" 
$ListName="Change Request"

#Array to hold column titles
$ColumnNames=@("Change Type","Approvers","Proposed Date and Time")

#Process each column
$ColumnNames | foreach {
    #Call the function to delete column from sharepoint list
    Remove-Column $WebURL $ListName $_
}
In some cases, instead of “$Column.Hidden=$False”, You may have to set: “$column.Sealed = $false”

As always, make sure you have backed up your data before deleting any columns. Because, when you delete a column, all the data in that column is also deleted. (There are no undo or restore from recycle bin options for columns!)

To delete a column from a SharePoint Online list, refer: How to Delete a Column from a List in SharePoint Online?

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!

5 thoughts on “SharePoint Server: How to Remove a Column from a List using PowerShell?

  • to remove the column from all sites, how can I change the script?

    Reply
  • Thanks, works very fine! Nice script.

    Reply
  • Hi folks,

    Your code is awesome but unfortunately the Update doesn’t work 🙁

    Reply

Leave a Reply

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