SharePoint Online: Change Alert Schedule using PowerShell

Requirement: Change the Alert Schedule from “Immediate” to “Daily” for all alerts of a specific user in a SharePoint Online site collection.

Business Case: A SharePoint User subscribed for alerts in various lists and libraries in a SharePoint Online site collection. Alerts were created with “Immediate” frequency which resulted in flooding his Inbox, as content added to these SharePoint Lists frequently. So the user wants to change the alert frequency to the daily summary for all alerts he has created. How to change the alert frequency from immediate to daily in SharePoint?

SharePoint users can update any of their existing alerts by:

  • Go to the list or library where you have the alert created >> Click on “Manage My Alerts” from the list settings toolbar.
  • Pick the alert from the list of alerts shown, to open it in edit mode.
  • Now you can adjust any property of the alert such as frequency, schedule, change type, etc.
    sharepoint online update alert using powershell

Updating each alert in a large site collection isn’t really an easy task, isn’t it? So, lets use PowerShell to update all alerts of a User in SharePoint Online site collection.

PowerShell to Change Alert Schedule in SharePoint Online:

Let’s use PowerShell to change the schedule of all alerts of a particular user in SharePoint Online site collection.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Custom Function to Set Alert Schedule 
Function Set-SPOAlertSchedule()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $UserID,
        [Parameter(Mandatory=$true)] [string] $Schedule
    Try {
        Write-host -f Yellow "Searching Site '$SiteURL' for Alerts of the User '$UserID'"

        #Setup Credentials to connect
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the web and its sub-sites
        $Web = $Ctx.Web

        #Get All Alerts of the User
        $User = $Web.EnsureUser($UserID)
        $UserAlerts = $User.Alerts

        #Loop through each alert
        #Write-host "Total Alerts of the User:"$UserAlerts.Count
        ForEach($Alert in $UserAlerts)
            #Update the Alert Schedule
            $Alert.AlertFrequency = [Microsoft.SharePoint.Client.AlertFrequency]::$Schedule 
            Write-host -f Green "Alert '$($Alert.Title)' Updated on list '$($Alert.List.Title)'!"

        #Iterate through each subsite of the current web and call the function recursively
        foreach ($Subweb in $Ctx.web.Webs)
            #Call the function recursively to process all subsites underneaththe current web
            Set-SPOAlertSchedule -SiteURL $Subweb.url -UserID $UserID -Schedule "Daily"
    Catch {
        write-host -f Red "Error Updating Alert!" $_.Exception.Message

#Call the function
Set-SPOAlertSchedule -SiteURL "" -UserID "[email protected]" -Schedule "Daily" 

You can update alerts in SharePoint On-premises with PowerShell: How to Update SharePoint Alerts using PowerShell

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply