Home > PowerShell, SharePoint 2010, SharePoint Administration > Hide Content Type Columns in SharePoint 2010 List Settings using PowerShell

Hide Content Type Columns in SharePoint 2010 List Settings using PowerShell

Recently I was asked “why can’t I hide my content type columns in my SharePoint 2010 list if the column types are set to (Yes/No)”.  This was something new to me.  I was unsure of the answer, but after looking at all the content type columns with their types set to Yes/No I noticed every single one of them did not have the option to change the list settings.  It was grayed out.  I needed to hide a few content type columns that had type sets of Yes/No but could not do it through the list settings.  So I turned to PowerShell.

If you ever run into this problem just follow my PowerShell script below to Hide/Unhide Content Type columns with their column type set, set to Yes/No. 

This script assumes you have a multiple Lists that have the same Content Type Columns that you want to hide.

If you only have 1 list than you would simply just remove the foreach loop and if statement and add this line after the $web call.

$list = $web.List[“Name of List”]

———————————————————————————————————————————————————————————–

$web = Get-SPWeb http://portal/site

foreach($list in $web.Lists) #Loop through each list in Site
{
 if($list.BaseType -eq “GenericList”)  #Only select SharePoint 2010 Lists
 {
  $contentTypes = $list.ContentTypes[“Name of Content Type”]
  $field = $contentTypes.FieldLinks[“Name of Content Type Column”]
  $field.Hidden = $true #Set the Content Type Column to Hidden
  $contentTypes.Update() #Update Content Type
  $list.Update() #Update List
 }
}
$web.Dispose()

———————————————————————————————————————————————————————————-

If you are not sure the name of the Content Type you can follow one of my other blogs to get the Content Type Name

http://jshidell.com/2012/08/16/finding-all-content-types-in-sharepoint-20072010-site-using-powershell/

If you want to reset the Content Type Column back to Optional, just replace this line:

$field.Hidden = $true

with

$field.Hidden = $false

Advertisements
  1. March 5, 2013 at 7:04 pm

    Can I use this script if I am not a farm adminstrator and have no access to the server? If so, how would I use it?

    • March 6, 2013 at 8:20 am

      Hi Keith,

      Unfortunately not. You would need to be able to log into one of your WFE servers with admin rights, and with enough elevated priviliages in SharePoint to execute the script.

  2. Arasu
    August 11, 2014 at 10:23 am

    Thanks a lot jShidell you saved my day i have tried different ways to hide the content type column without successful.. Finally you lead me to success.. great snippet once again thanks a lot…

    • August 14, 2014 at 12:29 pm

      No Problem. Glad it was helpeful.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: