2

I want to write a power-shell script to like a discussion item by a user. now i tried the following :-

$web = Get-SPWeb "http://**/" 
$list=$web.Lists.TryGetList("News");
$user = $web.EnsureUser("\user.test");
$doc = $list.GetItemById(330);
$likedBy = New-Object Microsoft.Sharepoint.SPFieldUserValue($web,  $user.ID, $user.LoginName);

$doc["DescendantLikesCount"] = "3";
$doc["LikesCount"] = "3";
$doc["LikedBy"].Add($likedBy);
$doc.UpdateOverwriteVersion() ;

now currently the like count will be set to 3, but when i hover over the "like", the popup will only list one user as follow, where i have like the item using the UI:-

enter image description here

so can anyone advice on this please? how i can add the user to show inside the users popup ? Thanks

Your Answer

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

Browse other questions tagged or ask your own question.