Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Auto-Follow Sites in SharePoint 2013
# Get UserProfile Manager
$site = Get-SPSite -Limit 1
$serviceContext = Get-SPServiceContext($site)
$profileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)
$profiles = $profileManager.GetEnumerator()
# Iterates through all the user profiles
foreach ($profile in $profiles)
{
$followingManager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($profile)
# Create a new social actor object for the site to follow
$socialActor = New-Object Microsoft.Office.Server.Social.SPSocialActorInfo
$socialActor.ContentUri = "http://intranet/sites/important-news-from-corp" # REPLACE THIS WITH YOUR SITE
$socialActor.ActorType = [Microsoft.Office.Server.Social.SPSocialActorType]::Site
# Follow the mandatory site
if (!$followingManager.IsFollowed($socialActor))
{
$followingManager.Follow($socialActor)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.