1

I am not sure if this is possible. I know there is a way to disable or delete an event handler using Powershell. But is there a way to pause an event handler using Powershell? I have three event handlers that trigger on a sharepoint list I have. but I do not want to delete it I just want to pause it.

  • 1
    Are you able to edit either the Script Editor, .html, .aspx, or .js file where the event handler is? If so you could just comment out the even handler's contents or declaration briefly. As far as I'm aware you can't do this with PowerShell. – KGlasier Dec 19 '18 at 17:55
  • @KGlasier Unfortunately I am not able to edit the script. Is there another way? Thanks – SharePoint Lady Dec 19 '18 at 22:27
2

From your question is not clear why you want to "pause" the event receiver, but I will assume you are creating/editing list items from PowerShell.

In this case it is possible to prevent event firing:

$assembly = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $assembly.GetType("Microsoft.SharePoint.SPEventManager");
$prop = $type.GetProperty([string]"EventFiringDisabled",`
[System.Reflection.BindingFlags] `
([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Static)); 
#SET EVENT FIRING DISABLED.
$prop.SetValue($null, $true, $null); 

<#
 DO WHAT YOU NEED TO DO
#>

#SET EVENT FIRING ENABLED.
$prop.SetValue($null, $false, $null); 

Script credits to Ivan Yankulov

  • I wanted to pause to ensure that I would be deleting the correct handler. The logic is that if it is the correct event handler I can delete or disable it. I am just not sure what is behind the event handler. Thanks – SharePoint Lady Dec 19 '18 at 22:29
1

There is no way to pause an event handler. You must disable or delete it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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