Friday, September 30, 2011

Disable Social Notification Emails in SharePoint 2010 Using PowerShell

Had client who wanted to pilot SharePoint 2010 User profiles for a select group of users.  They wanted to import all users from AD, but didn’t didn’t want non-pilot users to get e-mail notification of new colleagues as result of the notification timer job so I wrote below PowerShell script to turn this particular notification off.

Add-PSSnapin Microsoft.SharePoint.Powershell
#Set up default variables
#My Site URL

$mySiteUrl = ""

#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

$profiles = $profileManager.GetEnumerator()

foreach ($userProfile in $profiles) {
$userProfile["SPS-EmailOptin"].Value = 010

No comments:

Post a Comment