How to View all Event Receivers for a Site Collection in SharePoint

This article explains how you can view the list of event receivers attached to list/libraries in a site collection using PowerShell.

Introduction

 
Event receivers are methods executed when a specific trigger occurs in SharePoint. For instance, an item is added, based on which a code block is executed. Event receivers have always been a very useful point of entry for functionalities in SharePoint.
 
Follow along to find out how you can compile the list of event receivers in your site collection as per the below code. 
 
Code
  1. if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)   
  2. {  
  3.     Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
  4. }  
  5.  
  6. #Enter your site collection below  
  7. $site = Get-SPSite -Identity http://sharepoint.organization.com/sites/canon 
  8.   
  9. foreach ( $web in $site.AllWebs )  
  10. {  
  11.     Write-Host "Looking in web: " $web.Url  
  12.     foreach ($list in $web.Lists)  
  13.     {  
  14.         if ($list.EventReceivers.Count -gt 0){  
  15.             Write-Host $list.Title " has " $list.EventReceivers.Count " event receiver(s)"  
  16.             Write-Host "***********************************************************************************"  
  17.             $list.EventReceivers.Name  
  18.             Write-Host "***********************************************************************************"  
  19.         }  
  20.     }  

Usage

 
Just enter the site collection URL where you want to identify the event receivers and execute the code. The list containing event receivers will be displayed, along with the count and name of event receivers.
 
Output
 
The output will be printed on the screen. If needed, the code can be modified to direct the output to a text file also.
 
event-reciever-output-sharepoint 
 
The code can be found in my GitHub repo as well.
 

Summary

 
In this article, we learned how to view all of the event receivers for a site collection in SharePoint.