magritton
5/4/2016 - 8:49 PM

This lists all of the event receivers in a web site

This lists all of the event receivers in a web site

$web = get-spweb https://homeportnw.psns.navy.mil/cmdtools/tools/RDR
    $lists = $web.Lists | where {$_.EventReceivers.Count -gt 0}
    foreach ($list in $lists) {
        $evts = $list.EventReceivers ##| where {$_.Class -eq MyCompany.SharePoint.MyFeature.EventReceivers.MyEventReceiver"}
		$evts        
    }
$site = get-spsite -url http://portal
foreach ($web in $site.AllWebs) {
    $lists = $web.Lists | where {$_.EventReceivers.Count -gt 0}
    foreach ($list in $lists) {
        $evts = $list.EventReceivers | where {$_.Class -eq MyCompany.SharePoint.MyFeature.EventReceivers.MyEventReceiver"}
        if ($evts.Count -gt 0) {
            foreach ($evt in $evts) {
                Write-Host("Deleting..." + $list.RootFolder.ServerRelativeUrl + ", " + $evt.Type)
                $evt.Delete()
            }
        }
    }
}