none
Powershell script- add a "person or group" column with multiple user choice RRS feed

  • Question

  • Hi,

    I'm writing a script with Powershell and I'm trying to create a "person or group" column on a custom list, 

    but I need the user to select more than one person. (the option of "multiple users" needs to be checked).

    right now the code is : 

    $list.Fields.Add("Project team", "User", $User)

    maybe someone if familiar with the missing attribute?

    thanks :) !! 

    Wednesday, August 7, 2013 1:07 PM

Answers

All replies

  • Hi,

    According to your post, you wanted to create a “person or group” using PowerShell which can select more than one person.

    You can check with the following,


    $fldXml = "<Field Type='User' DisplayName='PersonCol1' List='UserInfo' ShowField='ImnName'

    UserSelectionMode='PeopleOnly' UserSelectionScope='0' Name='PersonCol1'/>"

    $myCustomList.Fields.AddFieldAsXml($fldXml,$true,Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)

     


    The above code will create people and group column ‘PersonCol1′ which allows only user(people) values but not user group names. Setting UserSelectionMode=’PeopleAndGroups’ will allow user group values. There are other possible values which can be set for ShowField attribute - Title, NameWithPicture, NameWithPictureAndDetails, ImnName (this is NameWithPresence)

    For more details, you can refer to the following article: http://adicodes.com/adding-fields-to-list-with-powershell-in-sharepoint-2010-part2/

    Thanks,

    Jason  Guo 


    • Edited by JasonGuo Thursday, August 8, 2013 5:39 AM format
    Thursday, August 8, 2013 5:37 AM
  • Hi, 

    Thanks :)! 

    I saw that article before,

    but what I need is not the option to select also groups - but to select more than one user.

    please see the screen shot, I need this radio button to be selected: "allow multiple selections"

    thank

    Thursday, August 8, 2013 6:44 AM
  • Hi,

    I’m really sorry to misunderstand you question.

    If you need the button “Allow multiple selections” to be selected, you can use the methods “AllowMultipleValues”.

    $column.AllowMultipleValues  = $true

    You can refer the following similar article to see more details: http://sharepointwings.blogspot.in/2012/05/update-lookup-field-settings-using.html

    Thanks,

    Jason Guo

    Thursday, August 8, 2013 8:25 AM
  • Sounds good I will give it a try :) thanks!! 
    Thursday, August 8, 2013 12:31 PM