Skip to main content
Add refelection option
Source Link
Per Jakobsen
  • 32.4k
  • 1
  • 35
  • 62

You can'tShouldn'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)

You can't.

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

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)
Source Link
Per Jakobsen
  • 32.4k
  • 1
  • 35
  • 62

You can't.

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