Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

Remove Following people from mysite for all users

$
0
0

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") $web = Get-SPWeb https://www.contoso.com/teams/yourteam $context = [Microsoft.SharePoint.SPServiceContext]::GetContext([Microsoft.SharePoint.SPSite]$web.Site) $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager $context $users = $web.AssociatedMemberGroup.Users | where IsDomainGroup -eq $false $useraccounts = $users | select loginname | Foreach {"$($_.loginname)"} foreach ($user in $users) { $profile = $upm.GetUserProfile($user.UserLogin) #$objectToFollowRelativeToWeb = "/" if ($profile) { #Create a Social Manager profile #SPSocialFollowingManager $followManager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($profile, $context) $following = $followManager.GetFollowed([Microsoft.Office.Server.Social.SPSocialActorTypes]::Users) for ($i=$following.Count - 1; $i -ge 0; $i--) { $followed = $following[$i] $acctname = $followed.AccountName #if claims: $acctname = 'i:0#.w|'+$acctname if ($acctname -iin $useraccounts ) { [Microsoft.Office.Server.Social.SPSocialFollowResult]$res = $followManager.StopFollowing($followed) Write-Verbose "$($user.UserLogin) stop following $acctname result is $res" } } } }


I have the above script from one of the technet solution to remove followeronly  for Contributors from MySite. I want this script to run for all user and remove all existing association. Can someone help me update this script.

Thanks Ba$va


Viewing all articles
Browse latest Browse all 21070

Trending Articles