How to hide Sharepoint List columns from Display form with powershell commad

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

$url = "url of your site";
$list = "List Name"; #list name
$fieldname = "Person";  # Field name

#Setting up context
$contextSite = New-Object Microsoft.SharePoint.SPSite($url);
$contextWeb = $contextSite.OpenWeb();

$list = $contextWeb.Lists.TryGetList($list);
$field = $list.Fields[$fieldname];

# Controls Field in New Form
$field.ShowInDisplayForm = 0;  #3 if you want to show then run again with 1 instead of 0 (1= true , 0=flase)

# Don't forget to update this field
$field.Update();

# And finally dispose everything.
$contextWeb.Dispose();
$contextSite.Dispose()

Comments

Post a Comment

Popular posts from this blog

Add attachment filed column in SharePoint custom list forms through SharePoint designer 2013

Get all column values based on a distinct column value from SharePoint list through rest api and json filters

Sharepoint 2013 interview Questions..