Setting 'Show field' for 'Person or Group' type column using PowerShell in SharePoint

Hi Friends,

While fixing one issue I needed to change the ‘Show field’ setting for “Person or Group” type of column like Modified By column, My first thought is to use ‘ShowField’ property of a column as I seen this property exist in <Field XML.

Bellow image shows the “show field” option on Edit column page.

 

I tried multiple option with ‘ShowField’ but no luck and the property was not changing, then after debugging the issue I found that we need to use column’s “LookupField” property to change the setting like following.

  1. Add-PSSnapin Microsoft.SharePoint.PowerShell  
  2. $webURL = "<Your web url>";  
  3. $web = Get-SPWeb $webURL;  
  4. $mylistName = "<Your list name>";  
  5. $mylist = $web.Lists[$mylistName];  
  6. $mycolumn = $mylist.Fields["Modified By"];  
  7. $mycolumn.LookupField = "Title";  
  8. $mycolumn.Update();  
  9. $mylist.Update();  
The other available options to set the ShowField are as following table: 
 
Sr. No. Show Field drop down options Exact value need to pass LookupField property
1 Name Title
2 Account Name
3 Work email EMail
4 Mobile phone MobilePhone
5 SIP Address SipAddress
6 Department Department
7 Title JobTitle
8 First name FirstName
9 Last name LastName
10 Work phone WorkPhone
11 User name UserName
12 Office Office
13 ID ID
14 Modified Modified
15 Created Created
16 Name (with presence) ImnName
17 Picture Only (36×36) PictureOnly_Size_36px
18 Picture Only (48×48) PictureOnly_Size_48px
19 Picture Only (72×72) PictureOnly_Size_72px
20 Name (with picture and details) NameWithPictureAndDetails
21 Content Type ContentTypeDisp

Hope this will help someone from developer community.