Some of you may have encountered the problem of deleting the InfoPath published columns. These columns are actually published as Content Types, so better we call them as content types. A custom column is easy to delete using OOB feature but deleting an InfoPath published column is pain in the arse. Below is a small script that will help you delete the InfoPath published columns.
Note: The below PowerShell Script can be use to delete any type of column - custom, InfoPath, or hidden
function Delete-WorkflowColumn ($webURL, $listName, $columnName)
{
#Setup variables from the user input
$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]
$column = $list.Fields[$columnName]
#Make sure the column is not hidden or read only
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.Update()
#Delete column and dispose of the web object
$list.Fields.Delete($column)
write-host "Deleted column"
$web.Dispose()
} //Press Enter
Delete-WorkflowColumn -webURL http://pro1:4444/sites/test -listName "EmpList"
That's All... You are Done !!!
Note: The below PowerShell Script can be use to delete any type of column - custom, InfoPath, or hidden
function Delete-WorkflowColumn ($webURL, $listName, $columnName)
{
#Setup variables from the user input
$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]
$column = $list.Fields[$columnName]
#Make sure the column is not hidden or read only
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.Update()
#Delete column and dispose of the web object
$list.Fields.Delete($column)
write-host "Deleted column"
$web.Dispose()
} //Press Enter
Delete-WorkflowColumn -webURL http://pro1:4444/sites/test -listName "EmpList"
-columnName "EmpAddress"
//Press EnterThat's All... You are Done !!!
0 comments:
Post a Comment