SharePoint Online: Get All Alerts from a Site Collection using PowerShell

Requirement: View all alerts in a SharePoint Online site collection.

How to get all alerts of a user in SharePoint Online?

Alerts are scoped at the web level in SharePoint. So, to get alerts of a user on a specific site, follow these steps:

  1. Navigate to the site >> Go to the Site Settings page.
  2. Click on the “User alerts” link under “Site Administration”.
  3. Select the user from the drop down and click on “Update” button to view all alerts.
    sharepoint online powershell get alerts
  4. This gets you all alerts of the selected user on the current site .

Now the question is: How to view all alerts of a SharePoint Online user for an entire site collection? PowerShell!

PowerShell to Fetch All Alerts from SharePoint Online

Here is the SharePoint Online PowerShell to get alerts from a 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"
Function Get-SPOWebAlerts($SiteURL)
    Try {
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Cred
        Write-host -f Yellow "Getting Alerts in the site" $SiteURL
        #Get All Alerts from the Web
        $Web = $Ctx.Web
        $WebAlerts = $Web.Alerts

        If($WebAlerts.count -gt 0) { Write-host -f Green "Found $($WebAlerts.Count) Alerts!"}

        $AlertCollection = @()
        #Loop through each alert of the web and get alert details
        ForEach($Alert in $webAlerts)
            #Get Alert list and User

            $AlertData = New-Object PSObject
            $AlertData | Add-Member NoteProperty SiteName($Web.Title)
            $AlertData | Add-Member NoteProperty SiteURL($Web.URL)
            $AlertData | Add-Member NoteProperty AlertTitle($Alert.Title)
            $AlertData | Add-Member NoteProperty AlertUser($Alert.User.Title)
            $AlertData | Add-Member NoteProperty AlertList($Alert.List.Title)
            $AlertData | Add-Member NoteProperty AlertFrequency($Alert.AlertFrequency)
            $AlertData | Add-Member NoteProperty AlertType($Alert.AlertType)
            $AlertData | Add-Member NoteProperty AlertEvent($Alert.EventType)
            #Add the result to an Array
            $AlertCollection += $AlertData
        #Export Alert Details to CSV file
        $AlertCollection | Export-CSV $ReportOutput -NoTypeInformation -Append

        #Iterate through each subsite of the current web and call the function recursively
        foreach ($Subweb in $web.Webs)
            #Call the function recursively to process all subsites underneath the current web
    Catch {
        write-host -f Red "Error Getting Alerts!" $_.Exception.Message

#Config Parameters
$SiteURL= ""

#Delete the Output Report, if exists
if (Test-Path $ReportOutput) { Remove-Item $ReportOutput }

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

#Call the function
Get-SPOWebAlerts $SiteURL

This PowerShell script gets alerts created in a site collection and generates a CSV file with all alerts in the provided site collection.

PnP PowerShell to Get All Alerts of a User in a Site 

To get all alerts of a user in a SharePoint Online site, use this PowerShell:

$SiteURL = ""
$UserID = "i:0#.f|membership|"

#Connect to SharePoint Online site
Connect-PnPOnline $SiteURL -interactive

#Get the User
$User = Get-PnPUser -Identity $UserID

#Get All Alerts of the User in the web
$Alerts = Get-PnPAlert -User $User

ForEach($Alert in $Alerts)
    #Get the List and List URL of the Alert
    $AlertList =  Get-PnPProperty -ClientObject $Alert -Property List
    $ListURL =  Get-PnPProperty -ClientObject $AlertList -Property DefaultViewURL

    #Fetch Alert Data
    $AlertData += New-Object PSObject -Property @{
        Title = $Alert.Title
        List = $AlertList.Title
        URL = $ListURL
        Frequency = $Alert.AlertFrequency
        AlertType = $Alert.AlertType
        EventType = $Alert.EventType

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

4 thoughts on “SharePoint Online: Get All Alerts from a Site Collection using PowerShell

  • I wanted to take this further but cannot make it work. Is there a way to get the alerts set by all users on a specific SharePoint library? I have a Policy library and want to know who has alerts set up on each file.

  • I ran both scripts and no alerts were detected. However there is a rule defined for the tenant and for the specific user.
    How come no output is generated?
    PS) I also looking for a script generating a full list of all configured DLP rules in the M365 online tenant. Perhaps you have such a script or can give a direction?
    Kind regards,

  • Hi, a bit off-topic maybe but one question:

    I have set up change alerts for my SP Online list. They work – as long as the changes are made through the web interface. But if I change items using PnP (Set-PnPListItem) I don´t get any alert. Is there any way to change that, so is there a way to let PnP initiated changed trigger the regular change alerts?

  • PS: I just found that the changes made through Set-PnpListItem don´t even change the last modified timestamp. So the change is actually done as kind of “hidden” change or something. Bug or intention? Just found the GitHub issues list. Will try to look for it there.


Leave a Reply

Your email address will not be published. Required fields are marked *