Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

Error:
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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.