by bronyx85 at 2013-04-09 12:01:22
Hi,by AlexBrassington at 2013-04-09 13:09:14
I have approx 100+ content types whose settings are Read Only on the root site.
I need to able to change this setting, so that they are not read only, but it needs to be done via powershell.
Can someone help me in such a way in which i can
a) get a list of all the content types and store them in a variable
b) loop through all the content types in the variable and change the settings so that they are not read only?
Many thanks
Content types exist at many levels but primarily at the root web of a site collection. The read only property is straight on the content type.by bronyx85 at 2013-04-09 23:18:28
Hi.by bronyx85 at 2013-04-10 06:06:25
Yes, they are the root level, but how do I change the read only setting via powershell for all content types in the system which are currently read only.
its ok. I have solved it.by AlexBrassington at 2013-04-12 11:05:28
A for each loop which queries the site, then loops through each library solved the issue.
thanks.
For anyone who finds this via search:Add-PSSnapin Microsoft.SharePoint.Powershell -ea SilentlyContinue
#Get site collection
$SiteCollection = Get-SPSite "http://sharepoint/sites/cthub"
#Groups
$ContentTypes = $SiteCollection.RootWeb.ContentTypes | ? {$.ReadOnly -eq $True -AND $.Hidden = $false }
foreach ($ContentType in $ContentTypes)
{
$ContentType.ReadOnly = $false
$ContentType.Update()
}
That’ll update all visible content types to be read/write. It would be much better to run it against a white-list of content types as even the visible one could lead to items that you shouldn’t be modifying being changed.