Tuesday, March 27, 2012

Find out the attaches SPEventReceivers on a given SPList

Small script to find out what event receivers are attached to a given list / document library.
Of course, you don't need that if you can have the luxury of having SharePointManager on your server.

if(-not(
Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})
) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
clear

$url = "https://myservername/mysite/mysubweb"
$listWebRelativeUrl = "/lists/thelist" # for a doc lib just "/DocLibName"

$site = Get-SPSite $url
$web = $site.OpenWeb()
$list =$web.GetList($web.ServerRelativeUrl + $listWebRelativeUrl)
$list.EventReceivers | foreach{write-host $_.Type " " $_.Name " " $_.ID}


$web.Dispose()
$site.Dispose()

No comments:

Post a Comment