Hey Everyone!!!
Today i will talk about List and Library Alerts and how can you get all Active alerts for a specific list using powershell script and how can you disable all alerts.
This is very useful script, when you need move a large list of items on a maintenance routine and you don’t want send a large number of emails/ notifications for users who subscribe alerts, this script help you disable and enable them.
This first PowerShell Script get all SharePoint list alerts with state active.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
#Variables
$WebURL = "http://YourWebUrl"
$ListName="YourListName"
#Function to Get All Active Alerts on a Given List
Function Get-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")}
foreach($Alert in $ListAlerts)
{
write-host "Alert' - $($Alert.Title)' Created for User - '$($Alert.User.Name)'"
}
#Dispose web object
$Web.Dispose()
}
#Call the function Appropriately to Disable or Enable Alerts
Disable-ListAlerts $WebURL $ListName
If you want disable all alerts on this specific list you just need run the following script.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
#Variables
$WebURL = "http://YourWebUrl"
$ListName="YourListName"
#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()
}
#Call the function Appropriately to Disable or Enable Alerts
Disable-ListAlerts $WebURL $ListName
Thanks
Fábio Carvalho
SharePoint Consultant
|create|it|

![[FIX] BizTalk Server 2010, 2013, 2013 R2 & 2016 errors “Class not registered (WinMgmt)” or “Access denied”](https://blogit.create.pt/wp-content/uploads/2018/07/access-black-and-white-blur-270514-218x150.jpg)

















Hi Fabio,
Thanks for sharing this useful article.
Hi Fabio,
Do you have a way to create SPonline alerts using PowerShell – I guess we will need pnp commands.
In the first example, the last lines should be:
#Call the function Appropriately to Display list Alerts
Get-ListAlerts $WebURL $ListName
Thanks for the script!
Can i migrate Active alerts from lists/library (sharepoint 2013) to SharePoint Online using this powershell script