For a massive update of a SharePoint list items I didn't want users, who subscribed for alerts about changes in the SharePoint list, got the messages about it. There were 2 ways to do it: 1 - temporary to disable SMTP server (change SMTP settings to wrong ones) and delete files from Queue folder after; 2 – temporary to disable alerts for a list. This story is about the second way.

There is a class SPAlert in SharePoint 2010. SPAlert provides information about the alert, such as alert frequency, user or UserID who created the alert, alert List. It also provides information about Status of alert.

You can modify SPAlert.Status value. For active alerts its value is "On", for inactive – "Off".

So, to disable alerts you should set SPAlert.Status value equal to "Off". The negative operation for enabling alert is to set SPAlert.Status value equal to "On".

Below a simple PowerShell code to manage SPAlerts status.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
    Write-Host "Plugging SharePoint modules"
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$siteUrl = "https://spsite/child/site/"
$spweb = Get-SPWeb $siteUrl

foreach($alert in $spweb.Alerts) {

# Uncomment the line below to Enable SPAlert
#   $alert.Status = "On"

# Uncomment line below to Disable SPAlert
#   $alert.Status = "Off"

    $alert.Update()

# Uncomment line below for information 
#Write-Host $alert.Title $alert.Status $alert.User
}