I would like to upload documents to a document library via Powershell and doing that.. I want to disable events that might be fired.
How can I set the EventFiringEnabled property from Powershell??
Not really something you generally do from PowerShell. The purpose of EventFiringEnabled is to prevent an event receiver from triggering the same event recursively.
However, you can switch it off for the thread upon which your PowerShell code is running.
$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);
#code to update list goes here!
Hope this helps!
Joel's SharePoint Architect Blog
Want SharePoint Training?
Microsoft 正在进行一项网上调查，以了解您对 Msdn 网站的意见。如果您选择参加，我们将会在您离开 Msdn 网站时向您显示该网上调查。