0

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?

  • 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
1

It takes two arguments:

public ActivityManager(
    UserProfile userProfile,
    SPServiceContext serviceContext
)

You are giving it a Microsoft.Office.Server.ServerContext, not a SPServiceContext.

MSDN Reference

  • also use Get-SPSite instead of instantiating a site object like that – Anders Rask Mar 8 '12 at 21:30
1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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