Saturday, November 14, 2009

Updating content type's and site column's group name using PowerShell

Few hours before deploying a SharePoint site I figured out that the group name of my Content Types and also the Site Columns are spelled incorrectly. I don’t want to delete and recreate neither the content types nor the site columns. So the options are: write console application that change the titles and run it on the server, or to make the same using PowerShell. And here are the steps to do it using PowerShell:

Making backup from your site is recommended.

1. First you need to have PowerShell installed on your server.
2. From the CMD, type Powershell then Enter
3. Import the SharePoint Assembly by typing [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

4. Create a site object from your site where the columns and the content types
$site = new-object Microsoft.SharePoint.SPSite(“http://cairo:4000”);

6. Update the Content Type group title
$site.rootweb.contenttypes[“TheContentTypeName”].Group = “TheNewGroupTitle”; $site.rootweb.contenttypes[“TheContentTypeName”].Update($true,$true);

8. Update the Site Column group title
$site.rootweb.Fields[“TheColumnName”].Group = “TheNewGroupTitle”; $site.rootweb.Fields[“TheColumnName”].Update();

10. Exit PowerShell
11. Test the related modules.

No comments: