I need to update an existing people picker column on a site, to narrow down the list of possible users that can be entered.
At present you can choose from All Users, I want to limit this to a particular SharePoint group. I need to do this on a large number of sites, so want to use PowerShell and CSOM.
I can get the relevant field with CSOM, but I don't know what value to change to limit the scope of the list of users. Can anyone help?
Here is what I have, to get the relevant field:
#————————————————————-
# LOAD CLIENT ASSEMBLIES
#————————————————————-
Add-Type -Path (Resolve-Path "$env:CommonProgramFiles\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "$env:CommonProgramFiles\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")
Add-Type -Path (Resolve-Path "$env:CommonProgramFiles\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll")
#————————————————————-
# INITIALIZE CONTEXT
#————————————————————-
$creds = Get-PnPStoredCredential -Name Creds -Type PSCredential
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName, $creds.Password)
$context.Credentials = $credentials
#————————————————————-
# LOAD LIST
#————————————————————-
[string] $originaListTitle = "List Title"
$listOriginal = $context.Web.Lists.GetByTitle($originaListTitle)
$context.Load($listOriginal)
$context.ExecuteQuery() # This loads the necessary list ID
$Field = $context.Web.AvailableFields.GetByInternalNameOrTitle("FieldName")
$context.Load($Field)
$context.ExecuteQuery()
Alternatively, if I have missed something in PnP-Powershell, I am happy to use that instead.
Thanks