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

How can I call DisableEventFiring using PowerShell?

C# code like this :

Type typeInfo = typeof(SPEventReceiverBase); 
MethodInfo disable = typeInfo.GetMethod("DisableEventFiring", BindingFlags.Instance | BindingFlags.NonPublic);
SPEventReceiverBase receiver = new SPEventReceiverBase();
 disable.Invoke(receiver, null);

I need do something like this using PS

share|improve this question

You can call this function only from inside an event receiver but not via powershell.

If you want to prevent a event receiver from being fired, you can use a power shell script to remove it.

Another option is to SharePoint Manager 2010 to remove the Event receiver.

share|improve this answer

You Shouldn't.

DisableEventFiring is only meant to be used inside EventReceivers. The main purpose is to prevent looping when they update items.

If you really REALLY want then it's almost identical to you c# code:

$receiver = New-Object "Microsoft.SharePoint.SPEventReceiverBase"
$type = $receiver.GetType()
[System.Reflection.BindingFlags]$flags = [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic
$method = $type.GetMethod("DisableEventFiring", $flags)
$method.Invoke($receiver, $null)
share|improve this answer
Thanks! I`ll try it. – Alexey Jun 4 '12 at 12:50

Here's how I did it but in most situations it is best not to disable event firing outside the event handlier/receiver:

$web = Get-SPWeb -Identity http://yoursharepointweb #FILL IN WITH YOUR WEB URL
$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)); 
$prop.SetValue($null, $true, $null); #SET EVENT FIRING DISABLED. 
$prop.SetValue($null, $false, $null); #SET EVENT FIRING ENABLED.

I use the above code in a situation where a workflow task is assigned to a "blank" user i.e. sometimes a user has no permissions on a SharePoint site but they are assigned a task by the initiator of the workflow. In this case the task is assigned to blank and the email alert is sent out but the Assigned To field on the task item remains blank.

share|improve this answer
How is this linked to the list or item? – PeterX Jun 18 '15 at 1:19

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.