Monday, August 25, 2014

SharePoint trouble shooting - update list data without event receiver triggered in powershell

Sometimes we need to run powershell to do batch update some list items, if the event receiver is active, the update process can be very slow. In this case, we will want to turn it off before batch update, then turn it back on.

Here is the powershell script to complete this,

# disable event firing
$my = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $my.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);
**** run times update ****

# enable event firing
$prop.SetValue($null, $false, $null);


1 comment:

talliewachter said...

Top casinos to play slots near you in Oklahoma
who is the ultimate 바카라 검증사이트 choice bet365 es for slots online. These are a few 토토 사이트 도메인 of the best casino sites 블랙 잭 in the world, and most of them provide them with 온라인 바카라 a