Monday, 24 October 2011

Turn off User Alerts in SharePoint 2010

Have you ever tried to turn off the user alerts in SharePoint 2010?

It would be easy to set up a user alert in SharePoint 2010 list however when someone comes back to you and say "Hey its bugging me with the alert mails as am getting 15, 20 mails everyday" you would say "No worries I can fix it" and then you would go back to the list searching how you can do this and then you realise "What?? I can't do it" and by that time you would have added 100 users to the list :S

-Yes you need either Control point or Powershell script to turn it off as SharePoint 2010 does not allow you to turn off all the alerts for the users at a time until unless each user logs in and modify it.

I ran into the same situation :D and finally have to get some Powershell script to turn it off.

This would be usefull to you :

++++++++//Script // +++++++++
Start-SPAssignment –Global
$web = Get-SPWeb "***URL of Site***"
$listurl = "***Relative URL of List***"
$IDS = ""
$alertCount = 0

foreach($alert in $web.Alerts)
{
if($alert.ListUrl -eq $ListUrl)
{
$alertCount = $alertCount + 1
Write-Host "Alerts Title :" $alert.title
$IDS += $alert.ID.tostring() + "|"

}
}

Write-Host "Number Of Alerts in List :" $listurl "=" $alertCount

Write-Host "Deleting... "
foreach($s in $IDS.Split("|"))
{
write-host -nonewline "*"
if($s –ne "")
{
$web.alerts.delete([GUID]$s)
}
}

$alertCount = 0

foreach($alert in $web.Alerts)
{
if($alert.ListUrl -eq $ListUrl)
{
$alertCount = $alertCount + 1
Write-Host "Alerts Title :" $alert.title

}
}

Write-Host "Number Of Alerts after REMOVAL in List :" $listurl "=" $alertCount

Stop-SPAssignment –Global

+++++++++++++++++++++++++++++++++++++++++