How to Follow a site URL with PowerShell in SharePoint 2013
Background
While migrating from SharePoint 2010 to 2013 we needed to take MyLinks and replace with new Social Site Following. Given a CSV with user names and site URLs I researched PowerShell options for programmatically making users follow sites. Now we can pre-populate Follow Sites before launch. The below code did the trick. ![]()
Code
Function AddSiteToUserFollow ($siteUrl, $userName) {
# Load site and user profile service
$site = Get-SPSite $siteUrl
$serviceContext = Get-SPServiceContext($site)
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)
if ($profileManager.UserExists($userName)) {
# Load user profile
$userProfile = $profileManager.GetUserProfile($userName)
# Load social following manager
$followingManager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($userProfile, $serviceContext)
# Prepare following object
$actorInfo = New-Object Microsoft.Office.Server.Social.SPSocialActorInfo
$actorInfo.ContentUri = $site.Url
$actorInfo.AccountName = $userProfile.AccountName
$actorInfo.ActorType = "Site"
# Add to followed sites
$followingManager.Follow($actorInfo)
}
}
AddSiteToUserFollow "http://sp15" "demo\sptest1"
Screenshots
References
Support
If the target user does not yet have a MySite created you could see the below error. The fix is simply to have them visit MySite – or – to upgrade their site collection from 2010 to 2013.
Exception calling “Follow” with “1” argument(s): “No personal site exists for the current user, and no further information is available. Internal type name: Microsoft.Office.Server.UserProfiles.SocialDataStoreException. Internal error code: 1.”

Is it possible to point this to tags/hashtags instead? I can`t seem to get it to work if i choose specific URLs (IE: http://intranet/sites/finance/default.aspx) Is this possible? Thanks for a great post!
Hi Espen, Yes that should be possible by changing lines 15-18 with detail on the class “SPSocialActorInfo.” Please see http://msdn.microsoft.com/en-us/library/microsoft.office.server.social.spsocialactorinfo_members(v=office.15).aspx for reference. I don’t have working code for this, but seems feasible with a little trial and error testing.
Hi Jeff, thanks for the reply! I have to be honest and admit that powershell is not my strong side here. I would be over the moon if you were able to help me abit with some code here 🙂 We have just gone live with SP2013 and we are having huge issues getting users to follow important tags to actually utilize the information that`s available.
Do you think you could help me out and get me on my way? (almost on my knees here) 🙂