Skip to main content
added 35 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

$UserCollection = @()
foreach($UserAccount in $UserAccountsColl)
{    
   #Get the User
    $User=$web.EnsureUser($UserAccount)
    $spuserValue = New-Object Microsoft.SharePoint.Client.FieldUserValue
    $spuserValue.LookupId = $User.id  
    $UserCollection += $spuserValue
}
$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$UserCollection 

#update the Multiple value Person or Group field
$ListItem[$FieldName] = $userValueCollection
$ListItem.Update()
$ClientContext.ExecuteQuery()

Hope this will help you.

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

$UserCollection = @()
foreach($UserAccount in $UserAccountsColl)
{    
   #Get the User
    $User=$web.EnsureUser($UserAccount)
    $spuserValue = New-Object Microsoft.SharePoint.Client.FieldUserValue
    $spuserValue.LookupId = $User.id  
    $UserCollection += $spuserValue
}
$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$UserCollection 

#update the Multiple value Person or Group field
$ListItem[$FieldName] = $userValueCollection
$ListItem.Update()

Hope this will help you.

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

$UserCollection = @()
foreach($UserAccount in $UserAccountsColl)
{    
   #Get the User
    $User=$web.EnsureUser($UserAccount)
    $spuserValue = New-Object Microsoft.SharePoint.Client.FieldUserValue
    $spuserValue.LookupId = $User.id  
    $UserCollection += $spuserValue
}
$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$UserCollection 

#update the Multiple value Person or Group field
$ListItem[$FieldName] = $userValueCollection
$ListItem.Update()
$ClientContext.ExecuteQuery()

Hope this will help you.

added 408 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

[Microsoft.SharePoint$UserCollection = @()
foreach($UserAccount in $UserAccountsColl)
{    
   #Get the User
    $User=$web.SPFieldUserValueCollection]$UserCollectionEnsureUser($UserAccount)
    $spuserValue = newNew-objectObject Microsoft.SharePoint.SPFieldUserValueCollectionClient.FieldUserValue
    $spuserValue.LookupId = $User.id  
    $UserCollection += $spuserValue
}
$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$UserCollection 

#update the Multiple value Person or Group field
$ListItem[$FieldName] = $userValueCollection
$ListItem.Update()

Hope this will help you.

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

[Microsoft.SharePoint.SPFieldUserValueCollection]$UserCollection = new-object Microsoft.SharePoint.SPFieldUserValueCollection

Hope this will help you.

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

$UserCollection = @()
foreach($UserAccount in $UserAccountsColl)
{    
   #Get the User
    $User=$web.EnsureUser($UserAccount)
    $spuserValue = New-Object Microsoft.SharePoint.Client.FieldUserValue
    $spuserValue.LookupId = $User.id  
    $UserCollection += $spuserValue
}
$userValueCollection = [Microsoft.SharePoint.Client.FieldUserValue[]]$UserCollection 

#update the Multiple value Person or Group field
$ListItem[$FieldName] = $userValueCollection
$ListItem.Update()

Hope this will help you.

added 357 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

TryLoad SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

[Microsoft.SharePoint.SPFieldUserValueCollection]$UserCollection = new-object Microsoft.SharePoint.SPFieldUserValueCollection

Hope this will help you.

Try to initialize $UserCollection as below in your code:

[Microsoft.SharePoint.SPFieldUserValueCollection]$UserCollection = new-object Microsoft.SharePoint.SPFieldUserValueCollection

Hope this will help you.

Load SharePoint CSOM assemblies in beginning:

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

And try to initialize $UserCollection as below in your code:

[Microsoft.SharePoint.SPFieldUserValueCollection]$UserCollection = new-object Microsoft.SharePoint.SPFieldUserValueCollection

Hope this will help you.

Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58
Loading