Example
1. We have got a document library with published content type "BaseDocument":
2. If we try deleting it from the library we are getting an error:
"The content type "X" at "Document Library Y" is read only."
Solution
Using SharePoint API we can update the ReadOnly property and then delete the content type.
Here's the PowerShell script sample:
$siteurl = "http://siteurl"
$ctname = "BaseDocument"
$libname = "Shared Documents"
$site = Get-SPSite $siteurl
$web = $site.OpenWeb()
$list = $web.Lists[$libname]
$ct = $list.ContentTypes[$ctname]
$ct.ReadOnly = $false
$ct.Update()
$list.ContentTypes.Delete($list.ContentTypes[$ctname].Id)
$list.Update()
Enjoy.
0 comments:
Post a Comment