Worried that lots of emails will be flooding out to all users when launched from the default emails settings in SharePoint 2010 Profiles. Well don’t below is a script to turn off the default settings. This is not our script but found on another site which we tested successfully.
Email Notifications:
The problems are that a new user to your organisation will still get all three options selected. This can only be used on current profiles.
Change the value "Value = 110;" to 1 or 0 for on or off
#Load the SharePoint snap-in
Add-PsSnapin Microsoft.SharePoint.PowerShell;
#Load the SharePoint assemblies
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server”);[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.UserProfiles”);if (($args -ne “Enable”) -and ($args -ne “Disable”)){
Write-Output “Unrecognized Argument: $args”;
exit;
}
#Specify the MySite URL
$MySiteUrl = “<MY Site URL>“;
#Get the server context for the profile manager
$site = Get-SPSite $MySiteUrl;
$ServerContext = Get-SPServiceContext $site;
$UPManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext);
#Count variables
$ucount = 0;
$enumProfiles = $UPManager.GetEnumerator();
“Total User Profiles available:” + $UPManager.Count
$count=0;
#Loop through the profile entries and update the property
#SharePoint Notification emails – SPS-EmailOptin (int)
#This field has 3 values one for each email type
foreach ($oUser in $enumProfiles)
{
$count = $count + 1;
$u = $oUser.Item(“Accountname”);
if ($args -eq “Enable”){
Write-Output “($count): $args Setting values for $u”;
$oUser["SPS-EmailOptin"].Value = 000;
$oUser.Commit();
}
else{
Write-Output “($count): $args Setting values for $u”;
$oUser["SPS-EmailOptin"].Value = 110;
$oUser.Commit();
}
}
#Dispose of site object
$site.Dispose();
No comments:
Post a Comment