Script requests - or examples

Nov 27, 2009 at 12:18 AM

Hi, having lost my patience with feature receivers and other methods to perform bulk operations, I'm now turning to PowerShell in the hope that it can do what others can't.

I'm looking for a way to unseal content types and site columns at the list level. And then reseal them after I've pushed down changes.

Ideally I'd like to just pass in a web app URL and the name of the content type and have the script traverse every site collection and web to locate the content type and change its sealed attribute.

Can this type of thing be done?

If so, I would really appreciate seeing an example of how to change list content type attributes.

Nov 28, 2009 at 6:16 PM

Hi panoone,
You can start with this script :


Fabrice Romelard [MVP]



Nov 29, 2009 at 9:50 PM

Hi Fabrice,

Thanks you. That's a great start and helps explain various methods to to grab web apps, differentiate between root sites and webs, and then iterate through them to identify specific information. As a PowerShell newbie I just have a couple of questions.

How do I run it?? :)

I've downloaded the script to the MOSS server and set the execution policy to RemoteSgined btu am gettign the following error:

Unable to find type [Microsoft.SharePoint.SPContentType]: make sure that the assembly containing this type is loaded.
At D:\PSscripts\GetContentTypeUsages.ps1:35 char:57
+ function ShowUsages([Microsoft.SharePoint.SPContentType]$ <<<< ContentType)

Also, the last lign of the script is uncommented. Should it be?

Can I specify a particular web application?

How can I modify the script to target a specific web application? Or allow me to pass in the name/URL of a web application?


...and this is probably a little way off given my current experience.

Once I've identified the lists using a particular CT, how do I go about changing the CT value for  every item in those lists?

Is it possible to re-use the returned object to perform an udpate task?


Thanks so much for your sample code and support. This is looking great!