Skip to content

Instantly share code, notes, and snippets.

@rheid
Created February 16, 2015 08:48
Show Gist options
  • Save rheid/a5ffa6a648f07453039d to your computer and use it in GitHub Desktop.
Save rheid/a5ffa6a648f07453039d to your computer and use it in GitHub Desktop.
Update SharePoint List with PowerShell without Events
# open web
$web = Get-SPWeb http://yoursite
# get list
$list = $web.Lists["Your List"]
# get item
$item = $list.GetItemById(1)
# disable event firing
$myAss = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint");
$type = $myAss.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);
# change properties
$item["Title"] = "New Title"
# update item (without changing the Modified or Modified By fields)
$item.SystemUpdate($false)
# enable event firing
$prop.SetValue($null, $true, $null);
@Mehmet-Erkan
Copy link

Any Chance to set the SPEventManager by REST API. I have needs for SharePoint Online

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment