Quantcast
Channel: Share Point Activity feed power shell script error - SharePoint Stack Exchange
Viewing all articles
Browse latest Browse all 3

Share Point Activity feed power shell script error

$
0
0
#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()


while($profile1.MoveNext())
{

        $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)
        $methodInfo.Invoke($am,$profile1.Current)

        $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              

              }
              else{
               $appt.IsSet = $true
              }
              $apptList.Add($appt)
            } # For Each Object Ending
        $am.ActivityPreferences.SetActivityPreferencesPerType($apptList)
        $am.ActivityPreferences.Commit()
        $am.ActivityPreferences.Refresh()
} # While Userprofile Ending`enter code here`

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images