SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Would like to work with the "ActivityManager" object however it is throwing an error:

$site = New-Object Microsoft.SharePoint.SPSite($siteurl)
$context = [Microsoft.Office.Server.ServerContext]::GetContext($site)
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profile = $upm.GetUserProfile([string]$loginname)
$am = New-Object Microsoft.Office.Server.ActivityFeed.ActivityManager($profile, $context)

New-Object : Cannot find an overload for "ActivityManager" and the argument count: "2".

any help?

Ok,it helps

$siteurl = "http://siteurl/";
$loginname = "domain/user";
$site = New-Object Microsoft.SharePoint.SPSite($siteurl);
$context = [Microsoft.Office.Server.ServerContext]::GetContext($site);
$ServerContext = Get-SPServiceContext $site;
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context);
$profile = $upm.GetUserProfile([string]$loginname);
$am = New-Object Microsoft.Office.Server.ActivityFeed.ActivityManager($profile, $ServerContext);

any help how can I deselect the "Manager change" newsfeed settings?

share|improve this question
i would ask you to add this question that you have added to a new one, as it is now a different topic. makes finding stuff in the archive easier – Sebastien Stettler Mar 8 '12 at 19:07
@karthikeyan please split up the questions into two seperate questions – Anders Rask Mar 8 '12 at 21:29
up vote 1 down vote accepted

it takes two arguments

public ActivityManager( UserProfile userProfile, SPServiceContext serviceContext )

you are giving it a Microsoft.Office.Server.ServerContext not a SPServiceContext

MSDN Referance

share|improve this answer
also use Get-SPSite instead of instantiating a site object like that – Anders Rask Mar 8 '12 at 21:30

To deselect a News feed setting, you would have to get the ActivityType from the ActivityTypes collection of ActivityManager class. And then use the IsSet property of the ActivityPreferencePerType to set the news feed to false.

But bear in mind that Microsoft disallows these settings from being changed by anyone except for the user who owns the account. In your case, running the code via console command while logged in as the farm administrator is not equal to the user's account for which the settings apply.

You can make a work around by somehow having the user run this code

share|improve this answer
thanks for your suggestion, could you share a reference? – Karthikeyan Mar 9 '12 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.