How to Delete a Column from SharePoint List Using PowerShell?
Learn how to delete a column from SharePoint list using PowerShell. Explore the complete PowerShell commands to remove a column from the SharePoint list.
No doubt, the SharePoint list is widely used in organizations. This is one of the efficient features of SharePoint for managing the data appropriately. But sometimes, there is a need to delete a column from the SharePoint list. It might be because of the outdated content, no further requirement of that column, and so on. Apart from the deletion, it is also important to delete the column in such a way that no other column data will be harmed. Therefore, in this article, we will discuss how to delete a column from SharePoint list using PowerShell.
Because PowerShell commands can automate the task. You can use the same script whenever required to perform the deletion of columns from the SharePoint list. We will also explore the Admin Center steps to delete the list’s column and the Site’s column. So, let's get started.
Prerequisites of Using PowerShell Commands for Column Deletion from SharePoint List
-
You should be well-versed in the PowerShell commands.
-
The SharePoint Online management shell should be up to date.
-
SharePoint List data should be stored on local storage or migrate SharePoint list to another site that you achieve by performing the SharePoint Migration Process.
-
Inform all of the affected users that are continuously using the SharePoint list.
Delete a Column from SharePoint List Using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$Site_URL="Enter here"
$List_Name="Accounts"
$Column_Name="Date"
$web = Get-SPWeb $Site_URL
$list = $web.Lists.TryGetList($List_Name)
if($List -ne $null)
{
$column = $list.Fields[$Column_Name]
if($column -ne $null)
{
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.AllowDeletion = $true
$column.Update()
$list.Fields.Delete($column)
write-host "Specified SharePoint List’s Column has been deleted"
}
else
{
write-host "Required Column is not found"
}
}
How to Delete a Column from SharePoint List Using SharePoint Admin Center?
You can delete the list’s column using the Interface if you are not good at the PowerShell commands. Let’s see how.
-
Open the SharePoint list whose column you want to delete.
-
Hit the Settings button and then List Settings.
-
Choose the Column title that is going to be deleted.
-
Now, scroll down and click on the Delete button.
Bulk Deletion of Columns from SharePoint List Using PowerShell Commands
After knowing how to delete a column from SharePoint list using PowerShell. Now, execute the below commands for deleting the columns from the SharePoint list in bulk.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Function Remove-Column-List($Web_URL, $List_Name, $Column_Name)
{
$web = Get-SPWeb $Web_URL
$list = $web.Lists.TryGetList($List_Name)
if($List -ne $null)
{
$column = $list.Fields[$Column_Name]
if($column -ne $null)
{
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.AllowDeletion = $true
$column.Update()
$list.Fields.Delete($column)
}
else
{
write-host "unable to find the required column"
}
}
else
{
write-host "Searched SharePoint List is not found!"
}
}
$Web_URL=""
$List_Name="Accounts"
$Column_Names=@("Change Type","Approvers","Proposed Date and Time")
$Column_Names | foreach {
Remove-Column-List $Web_URL $List_Name $_
}
How to Delete a Site’s Column Using Admin Center?
Follow the below steps sequentially to remove the column from the SharePoint site.
-
Move to the Site Actions and then Site Settings.
-
Hit the “Site Columns” option under the Web Designer Galleries.
-
Now from the site columns page, hit the Title of the site column to fetch the target site column.
-
Find out the Delete button and then click on it to confirm the prompt.
How to Delete a Site Column in SharePoint?
You can delete the site column as well if required. But you need to make sure that it is no further required. Also, take permission from other users that are accessing the site.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$Root_Web_URL ="Complete URL Here"
$Site_Column_To_Remove="Sales"
$Root_Web = Get-SPWeb $Root_Web_URL
if ($Root_Web.Fields.ContainsField($Site_Column_To_Remove))
{
$Root_Web.Fields.Delete($Site_Column_To_Remove)
Write-host "Site’s column has been deleted"
}
Final Words
In this article, we have discussed how to delete a column from SharePoint list using PowerShell. It is quite difficult when you need to delete the column using PowerShell. But following the above-discussed commands, you can easily delete the required column from the SharePoint list. Also, make sure you are fulfilling the above prerequisites before performing column deletion.
What's Your Reaction?






