Requirement: Temporarily disable Alert Emails on a SharePoint list.
Solution:
SharePoint Alert objects have "Status" property which can be turned ON or OFF. As there is no UI to disable or enable alerts in SharePoint directly from the browser, we can do it programmatically with PowerShell. Here is my PowerShell script to disable alerts on SharePoint 2010/2013 listor library.
PowerShell script to Disable alerts on SharePoint list
Related Posts:
Solution:
SharePoint Alert objects have "Status" property which can be turned ON or OFF. As there is no UI to disable or enable alerts in SharePoint directly from the browser, we can do it programmatically with PowerShell. Here is my PowerShell script to disable alerts on SharePoint 2010/2013 listor library.
PowerShell script to Disable alerts on SharePoint list
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
#Function to Disable All Active Alerts on a Given List
Function Disable-ListAlerts($WebURL, $ListName)
{
#Get the Web and List objects
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)
#Get All Alerts created in the list - Which are Active
$ListAlerts = $Web.Alerts | Where-Object {($_.List.Title -eq $List.Title) -and ($_.Status -eq "ON")}
Write-host "Total Number of Active Alerts Found in the list: $($ListAlerts.Count)"
#Iterate through each alert and turn it OFF
foreach($Alert in $ListAlerts)
{
$Alert.Status="OFF"
$Alert.Update()
write-host "Disabled the Alert' $($Alert.Title)' Created for User '$($Alert.User.Name)'"
}
#Dispose web object
$Web.Dispose()
}
#Function to Enable all Disable Alerts on a Given List
Function Enable-ListAlerts($WebURL, $ListName)
{
#Get the Web and List objects
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)
#Get All Alerts created in the list - Which are in Disabled State
$ListAlerts = $Web.Alerts | Where-Object { ($_.List.Title -eq $List.Title) -and ($_.Status -eq "OFF")}
Write-host "Total Number of Disabled Alerts Found in the list: $($ListAlerts.Count)"
#Iterate through each alert and turn it OFF
foreach($Alert in $ListAlerts)
{
$Alert.Status="ON"
$Alert.Update()
write-host "Enabled the Alert' $($Alert.Title)' Created for User '$($Alert.User.Name)'"
}
#Dispose web object
$Web.Dispose()
}
#Variables
$WebURL = "http://operations.crescent.com/"
$ListName="Proposal Documents"
#Call the function Appropriately to Disable or Enable Alerts
Disable-ListAlerts $WebURL $ListName
#To Enable it back
#Enable-ListAlerts $WebURL $ListName
Related Posts:
- Disable Alerts from a SharePoint 2010 List or Library with C#
- Disable alert me in SharePoint 2007/2010/2013 - How to Disable All Alerts in SharePoint
- Create - Edit - Find - Delete SharePoint Alerts using PowerShell