Enable/Disable SharePoint OOTB SPAlerts using PowerShell

SPAlerts aka User Alerts is one of nice feature that SharePoint provides OOTB, This feature get automatically enabled once we configure SMTP Outbound mail address in Central Admin. 
Basically it has 3 types of Alerts Frequency:

  • Immediate
  • Daily
  • Weekly 

Each runs on it own respective TimerJob in CA.User can set alerts for both List/Library level or item level for any existing and newly created SPList/Lib objects. 


However, There is no UI option available in SharePoint to enable/disable this feature per User/List/Library level; Without deleting it. But some time our requirements are never been interesting that we need to disable alerts for Specific User or All the users from specific List/Library



$oWeb = Get-SPWeb "https://site.domain.com/sites/web"
$oList = $oWeb.Lists.TryGetList("Communication")

# Get all alert
# $alerts =  $oWeb.Alerts | ? { ($_.List.Title -eq $oList.Title) }

# Get alerts of specific frequency
$alerts =  $oWeb.Alerts | ? { ($_.AlertFrequency -eq "Immediate") -and ($_.List.Title -eq $oList.Title) }
    
foreach($alert in $alerts)
{
   $alert.Status = "Off"
   $alert.Update()
}



Download full source code
PS1: Enable-Disable SPAlerts.ps1

Related articles:

Remove complete user access from SharePoint using PowerShell
Load Assembly references in PowerShell
Declare Global Variables in PowerShell
Pass/Read Command Line arguments
Convert DateTime based on regional settings in PowerShell
Read RESX value in PowerShell
Perform CAML Query in PowerShell



🔔⏳🔶🔷 Note 🔷🔶⏳🔔

This will only enable/disable existing user from the mentioned list/library. We need to schedule it as a job to repeat this for every new Alert subscriber.

-Ratsub

Comments

Popular posts from this blog

People picker Control in PowerApps

Secure When a HTTP request is received Power Automate a.k.a MS Flow

Upload attachment to SharePoint list item using Microsoft Flow

Modern page provisioning using page template

REST call returns XML instead of JSON in SharePoint

HTML field & Date Time formatting in powerapps

Step-By-Step Azure AD App Registration

Approval and auto escalation with time out in Microsoft Flow

Developing custom reusable components in PowerApps

Create and configure custom connectors for PowerApps and MSFlow from AzureFunctions