1

I try to update a SharePoint Online people field (in a doc list), from PowerShell.

Here's the code:

$properties = $Upload.ListItemAllFields;
$context.Load($properties)
$properties["CLT"] = $File.Name.Substring(0,10)
$spcompte = Get-SPOUser -Site https://xxxx.sharepoint.com/ -LoginName "xxxx@xxxx.onmicrosoft.com" 
$properties["ACCOUNT"] = $spcomte
$properties.Update()

No problems with a $spcompte.displayname, it shows the correct user,

But $properties["ACCOUNT"] = $spcomte just returns the following :

Exception calling "ExecuteQuery" with "0" argument(s): "Des données non valides ont été utilisées pour mettre à jour l'élément de liste. Le champ que vous essayez de mettre à jour est peut-être en lecture seule." At C:\Sharepoint PowerShell.ps1:50 char:1 + $Context.ExecuteQuery() + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ServerException

Google translate for the error:

Invalid data was used to update the list item . The field you are trying to update may be read only.

Any idea? I see a lot of stuff about Get-SPUser for SharePoint server, but nothing for Online.

  • I would just try setting it with their email address and let it do the validation and everything normally, rather than trying to pass in an object. – Eric Alexander Jun 26 '15 at 13:55
0

I have the same problem. I found the solution at last, so I would like to share with you if it helps

$SiteUrl = "Your site URL"

$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 

$Item["Title of column"] = $Context.Web.EnsureUser("e-mail of user") 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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