Archive for October, 2011

Oct 06 2011

Update SharePoint List ContentType Names

Published by under .NET

I know it’s been a while since I last posted but this is going to be short and sweet.  I’ve just been working on a SharePoint 2010 site where I’ve need to change the names of site content types and have the changes pushed down to a list that already uses the content types.

The content types are deployed using a solution but that’s where the automation ends.  However, this is where Powershell steps up to the mark.  With Powershell we can quickly automate just about anything in SharePoint.

Here’s the script I can up with:

$web = Get-SPWeb http://www.example.com
$list = $web.Lists["TargetList"]
$list.ContentTypes | ForEach {
    $_.Name = $_.Parent.Name
    $_.Update()
}

No responses yet