1

How do you set sharepoint user field to allow multiple users with powershell?

Add-PnPField -List $RecordListName -DisplayName $fieldName -InternalName $fieldName  -Type User -Required -AllowMultipleValues -ErrorAction Continue -AddToDefaultView | Out-Null

Tried using -AllowMultipleValues but get the below error

Error: A parameter cannot be found that matches parameter name 'AllowMultipleValues'.

1 Answer 1

0

In order to add a multi-choice user field, you need to use the Add-PnPFieldFromXML method.

Also, the multi-choice user field is a not a simple property. In fact, it's a totally different field type: Type="UserMulti":

$fieldXml = '<Field Type="UserMulti" DisplayName="Demo Presentors" List="UserInfo" Required="FALSE" ID="{bd66d0d0-c441-4ce3-909a-204ff01cdcb7}" ShowField="EMail" UserSelectionMode="PeopleOnly" StaticName="DemoPresentors" Name="DemoPresentors" Mult="TRUE" />'

Add-PnPFieldFromXml -List $RecordListName -FieldXml $fieldXml
2
  • Is there a way to pass a GUID variable to the xml? I am passing the variable fieldID and get Add-PnPFieldFromXml : Expected hex 0x in '{0}'. $FieldID = New-Guid $fieldXml = '<Field Type="UserMulti" DisplayName="Auxiliary_Admin" List="SiteRecord" Required="FALSE" ID="{$fieldID}" ShowField="Email" UserSelectionMode="PeopleOnly" StaticName="Auxiliary_Admin" Name="Auxiliary_Admin" Mult="TRUE" />' $fieldID Add-PnPFieldFromXml -List $RecordListName -FieldXml $fieldXml Commented Jul 27, 2021 at 18:14
  • Sure, the XML is just a string. So you can parameterize it. For example, ... ID=$GUID Commented Jul 27, 2021 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.