Forum Discussion
Problem in Deleting Remote Event Receiver in Sharepoint
You can do this first by searching it in the SharePoint ClientBrowser and then use a powershell script to delete it.
function Get-SPOListEventreceivers { param ( [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, [Parameter(Mandatory=$true,Position=3)] [string]$Url, [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] [GUID]$EventReceiverGUID ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) try { $ctx.ExecuteQuery() } catch [Net.WebException] { Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red } $ctx.Load($ctx.Site) $lista=$ctx.Web.Lists.GetByTitle($ListTitle) $ctx.Load($lista) $ctx.ExecuteQuery() $recevery=$lista.EventReceivers $ctx.Load($recevery) $ctx.ExecuteQuery() Write-Host "Found " $recevery.Count " receivers in " $lista.Title $recevery.GetById($EventReceiverGUID).DeleteObject() try { $ctx.ExecuteQuery() Write-Host "receiver removed" } catch [Net.WebException] { Write-Host "Failed to delete the receiver" $_.Exception.Message.ToString() -ForegroundColor Red } } # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" # Insert the credentials and the name of the admin site $Username="spadmin@xxx.onmicrosoft.com" $password = "$xxxx" $url = "https://xxxx.sharepoint.com/sites/S046WW16776" $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $Url="https://xxx.sharepoint.com/sites/S046WW16776" $ListTitle="Project Metadata" $EventReceiverGUID="8ded46d9-6b87-4dac-9532-64d013122e92" Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url -ListTitle $ListTitle -EventReceiverGUID $EventreceiverGUID
- Prerak DesaiJun 03, 2017Copper Contributor
Powershell method gives access denied error. Is there any way we can deleted the event receiver without deleting the list
- john johnFeb 12, 2020Iron Contributor
Prerak DesaiI am facing the exact same issue.. unable to remove the RER using PnP either
- bhartisemwal1990Feb 12, 2020Copper Contributor
Hi john may I know if you are using sharepoint online version or on premise version??
As RER can be removed by the app that registered it. In our scenario farm realm id got changed because of which even the same app was not able to delete the remote event receiver.
In order to get rid of the remote event receiver we used brute force . Instead of client side code we wrote server side PowerShell script to delete the remote event receiver which worked for us.
- bhartisemwal1990Nov 24, 2016Copper Contributor
yeah i think now powershell is the only option .
Because the issue was not with the appid change but the farm id change because of which the entire AppId was not matching and hence giving access denied error.
Thanks for replies :)