I will show you another piece of code that I use during development.
In this case I need to get the rating of a document. In C# the code looks like this:
using (SPSite site = new SPSite("SharePoint site URL"))
SPServiceContext context = SPServiceContext.GetContext(site);
SocialRatingManager mySocialRatingManager = new SocialRatingManager(context);
SocialRating aRating = mySocialRatingManager.GetRating(myUri);
Console.WriteLine(aRating.Url + ": " + aRating.Rating);
To do the same with powershell we must do some changes. I show to you:
$siteUrl = Read-Host "Site url"
$site = Get-SPSite $siteUrl
$uri = Read-Host "Uri document"
$serviceCtx = Get-SPServiceContext -Site $site
$socialRatingMgr = New-Object Microsoft.Office.Server.SocialData.SocialRatingManager($serviceCtx)
$rating = $socialRatingMgr.GetRating($uri)
$rating | Format-Table -AutoSize -Wrap
I want remember that I’m not a powershell guy but I like it to use for my general purpose