Attempting to use PowerShell to obtain some social metrics from our SharePoint farm. One metric I wanted to get was the average number of sites users are following. The following script runs without errors, but the GetFollowedCount for each user returns 0 sites, even if they are following many.
$site = Get-SPSite https://mysite.server.com
$servContext = Get-SPServiceContext($site)
$profileMgr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($servContext)
$typeSite = [Microsoft.Office.Server.Social.SPSocialActorTypes]::Sites
$profiles = $profileMgr.GetEnumerator()
$count = 0
$siteFollows = 0
foreach ($person in $profiles)
{
if($person.PersonalSite.Url)
{
$followMgr = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($person)
$count++
$thisSiteFollows = $followMgr.GetFollowedCount($typeSite)
$siteFollows = $siteFollows+$thisSiteFollows
Write-Host "Sites Followed by " $person.AccountName ": " $thisSiteFollows
}
}
$averageSites = $siteFollows/$count
Write-Host "Average Sites Followed: " $averageSites
Need help figuring out what it is I'm missing. Thanks.