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
#Add SharePoint PowerShell SnapIn if not already added
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"

[void] [System.Reflection.Assembly]::LoadWithPartialName("System")

$site = Get-SPSite "http://mysite/"
$context = Get-SPServiceContext $site;
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context);
$profile1 = $upm.GetEnumerator()


        $am = New-Object Microsoft.Office.Server.ActivityFeed.ActivityManager($myprofile1, $context)

        $type = $am.GetType()
        $methodInfo = $type.GetMethod("CopyBasicUserInfo", [reflection.bindingflags]"nonpublic,instance", $null, $profile1.GetType(), $null)

        $apptList = New-Object System.Collections.Generic.List[Microsoft.Office.Server.ActivityFeed.ActivityPreferencePerType]

        $am.ActivityApplications["UserProfileChange_Gatherer"].ActivityTypes | ForEach-Object {
              $appt = New-Object Microsoft.Office.Server.ActivityFeed.ActivityPreferencePerType
              $appt.ActivityType = $_ 
              $Username = $profile1.Current.DisplayName

              if($_.ActivityTypeName -eq "Birthday_Reminder") {
                $appt.IsSet = $false
                write-host "Updating Activity Feed Property Birthday_Reminder for " $Username              

               $appt.IsSet = $true
            } # For Each Object Ending
} # While Userprofile Ending`enter code here`

While the above code is working for all user profiles i want to limit the update only to a specific group of users ,For that purpose i had created audience in admin ,But i don't know how to call that group of Audience from Power Shell Code.Can anyone please suggest me how to achieve that..

share|improve this question
up vote 0 down vote accepted

To work with audiences you need to get the AudienceManager

To get the userprofiles for an audience you can do the following:

$site = Get-SPSite "http://mysite/" 
$context = Get-SPServiceContext $site; 
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context); 
$audmgr = New-Object Microsoft.Office.Server.Audience.AudienceManager($context)
$aud = $audmgr.GetAudience("Managers")
$aud.GetMembership() | % {$upm.GetUserProfile($_.NtName)}
share|improve this answer
Can you give me some more insight on that . I am very new to powershell... – Anil Apr 17 '12 at 20:07
Hi I am using the audience manager class but how can i loop through only specific group of audience ... – Anil Apr 17 '12 at 20:23
Example added to answer – Per Jakobsen Apr 18 '12 at 16:27
Thank you .It helped me to fix the issue – Anil Apr 18 '12 at 22:03

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.