SharePoint 2013 PowerShell Script Hide a Column Yes/No type in a Site Content Type

InfoPath alternatives for form designing SharePoint

In this post we will discuss how we can hide Yes/No column type from a Site content type in SharePoint 2013 using PowerShell.

You may also read:
– Get Users who is not having My site from the User Profiles in SharePoint using PowerShell Script in SharePoint 2013

– Powershell Script to copy the Files from one Folder to another Folder in Site collection with Exact Fields and File Versions

– SharePoint 2013 Online Content Search WebPart with Query String

I got an Requirement that to hide an Yes/No Field in Custom list called “ABC” . But after analysis came to know that field is coming from the content type called “xyz”. So my first approach is from Visual Studio and made a code change to that field and added a property called “hidden= true”. But that field property is not reflecting in the SharePoint list not even in Content type as well, from other blogs and colleague suggestions came to know that you cannot hide a existing field of type “yes/no” from .wsp deployment. So, found a way that using PScript we can hide the yes/no field . Here is the Code follows

Add-PsSnapin Microsoft.SharePoint.PowerShell
$site = Get-SPSite “Site URL”
$web = $site.RootWeb
$web.AllowUnsafeUpdates = $true
$ct = $web.ContentTypes[‘Content Type Name’]
$field = $ct.FieldLinks[” FieldInternalName “]
$field.Hidden = $true
$web.AllowUnsafeUpdates = $false
Write-Host “Field is hidden in the content type”

Once PSScript can verify in content type you can see that field has been hidden.

Hope this will be helpful.

Similar SharePoint 2013 Tutorials

About Sravan kumar

I am a SharePoint Developer Working in Reputed MNC company Bangalore.

View all posts by Sravan kumar →

Leave a Reply