Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top