1

I have a Content Database that contains Event Receivers referring to a Solution / Feature that was incorrectly removed. These Event Receivers are embedded in every Content Type in my Site Collection and prevent me from creating new Sites.

Using SharePoint Manager 2010 I can view the references using "Site Collection > Content Types > Event Receivers", but not delete / remove them.

I found a similar question here: Content Type Event Receivers Impossible to Remove, but am unable to remove the event receivers.

Is there anyone here that can help me delete these event receivers?


Answer provided by Hugh Wood

Powershell code used for the deletion of event-receivers in the announcement content type:

$site = Get-SPSite "http://url"
$web = $site.RootWeb
$ct = $web.ContentTypes["Announcement"]
$ct.EventReceivers
$ct.EventReceivers[0].delete()
$ct.update()

I created the following powershell script to remove the Event Receivers from the Content Types. The script requires the name of the Content Type as a parameter. It counts the total number of event receivers registered and deletes them via a while-loop.

Attention: This script does not validate the Event Receiver name. It deletes all Event Receivers found for the given Content Type name.

Param(
    [parameter(Mandatory=$true)]
    [alias("ContentTypeName")]
    $r_ContentTypeName)

$r_input= $r_ContentTypeName
echo $r_ContentTypeName
#$r_input= Read-Host 'What is the Content Type Name?'
$site = Get-SPSite "URLGoesHere"
$web = $site.RootWeb
$ct = $web.ContentTypes[$invoer]
$ct.EventReceivers
$i = 0
$aantal = $ct.eventreceivers.count
while ($i -le $aantal)
{
$ct.EventReceivers[0].delete()
$ct.update()
$i++
}
$ct.update()

Please post your adaptation of this script to help other people experiencing this issue.

2 Answers 2

1

You can delete them in SharePoint Manager, go to the list not the event receivers section, there is an event receiver section under the content types, right click the receiver and remove it.

[update] This similar answer has the answer on how to force a deletion: Content Type Event Receivers Impossible to Remove

You can loop through all of the target content types one by one by iterating through their collection.

6
  • Strangely the Event Receivers list beneath the Content Types in SharePoint Managers is empty. There are no event receivers to delete. The event receivers are only visible in the Content Types section.
    – TempaC
    Nov 8, 2012 at 9:24
  • 1
    Try changing the view to Full.
    – Hugh Wood
    Nov 8, 2012 at 9:25
  • The view was already set to Full. It is still empty.
    – TempaC
    Nov 8, 2012 at 10:19
  • 1
    Take a look at this similar question: sharepoint.stackexchange.com/questions/27466/…
    – Hugh Wood
    Nov 8, 2012 at 10:22
  • 1
    I updated the answer to reflect this, and add the code to your question.
    – Hugh Wood
    Nov 8, 2012 at 10:48
1
  1. Using object model/powershell you can loop through all available content types.
  2. Then for each content type check if it has receiver = your receiver name
  3. If so delete
  4. Then finally update the content type + its children if any
  5. Save SPWeb object if required
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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