SharePoint : Delete “Scheduling Start Date” and “Scheduling End Date” columns using PowerShell

In general, we can delete the columns using UI from SharePoint pretty easily. But some columns are not allowed to be deleted using UI but are allowed to be deleted using PowerShell. But there are some columns which are not deleted from PowerShell as well without some tweaks.

Following is the snippet for deleting the column using PowerShell:

$site = Get-SPSite "<SITE_URL>"
$web = $site.OpenWeb("<WEBURL>") or $site.RootWeb
$list = $web.Lists["<List_DISPLAY_NAME>"]
$fieldToBeDeleted = $list.Fields["FIELD_DISPLAY_NAME"]
$list.Fields.Delete($fieldToBeDeleted)

Normally, the above code works like charm. But it won’t work for the columns “Scheduling Start Date” and “Scheduling End Date” as they are sealed columns. For more information about sealed columns check MSDN. So, the above script would need a slight modification.

$site = Get-SPSite "<SITE_URL>"
$web = $site.OpenWeb("<WEBURL>") or $site.RootWeb
$list = $web.Lists["<List_DISPLAY_NAME>"]
$fieldToBeDeleted = $list.Fields["FIELD_DISPLAY_NAME"]
$fieldToBeDeleted.Sealed = $false
$fieldToBeDeleted.Update()
$list.Fields.Delete($fieldToBeDeleted)

Hope it helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s