SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lately i had a bug that time-to-time added duplicate event receiver entries in SPEventReceiverDefinitionCollection.

So how do i easily enumerate and remove these duplicate entries?

share|improve this question
$list.EventReceivers | 
    group-object assembly, class, type | #Groups event receiver by assembly/class/type
    ? { $_.Count -gt 1 } |    #If any of assembly/class/type pairs are encountered more than once, we have a duplicate
    % { $_.Group[1..100] }  #enumerate starting from second item (indexed at 1), so we don't delete event receiver completely
    # | % { $_.Delete() } #Uncomment this to perform delete.

Thanks to this blog post for showing the way: Finding (and Deleting) Duplicate Files

share|improve this answer
Great answer, was just about to start writing this PS myself so you've saved me time :-) – Brian Scott Apr 9 '12 at 15:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.