Created
February 16, 2015 08:48
-
-
Save rheid/a5ffa6a648f07453039d to your computer and use it in GitHub Desktop.
Update SharePoint List with PowerShell without Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any Chance to set the SPEventManager by REST API. I have needs for SharePoint Online