0

I'm reasonably new to PowerShell and have created a script to deploy a list into SharePoint using PNP PowerShell. One of the list items is a user field that is created with the following line

Add-PnPField -List "Owners" -DisplayName "Owner" -InternalName Owner -Type User -Required -ErrorAction Continue -AddToDefaultView | Out-Null

Can anyone tell me how I set this field to be users only and not users & groups?

1 Answer 1

0

This is unfortunately not possible via the Add-PnPField command, so what you can do is use Add-PnPField to add the field first and then use Set-PnPField to modify the field to make it PeopleOnly.

You can do that as below:

$field = Add-PnPField -List "Owners" -DisplayName "Owner" -InternalName Owner -Type User -Required -ErrorAction Continue -AddToDefaultView | Out-Null

Set-PnPField -List "Owners" -Identity $field.Id -Values @{"SelectionMode"=0}
1
  • Thanks for the help Gautam I was getting an error because $field was null but i fixed it by adding a line to get the id of the owner column between the two $field = Get-PnPField -List "Owners" -Identity "Owner" Commented Jul 30, 2020 at 15:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.