PNP Powershell how to use Add-PnPField -type user to set to users only
-
14-02-2021 - |
Question
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?
La solution
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}
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange