Tags: , , , | Posted by BPOS-Tutor on 4/22/2011 9:16 AM | Comments (0)

You can call the .Update function in order to try and fire either an out of the box or custom event receiver.  If your library required document check out you will need to first check out the document(s) in the library that have an event receiver.  Here's a sample PowerShell script that will do just that.

[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$weburl="http://records"
$contenttype="Court Document"
$site = new-object Microsoft.SharePoint.SPSite($weburl)
$web = $site.OpenWeb()
$list = $web.Lists["Claim / Litigation"]
$list | foreach {$_.Items|select Name, ContentType}
$caml='<Where><Eq><FieldRef Name="ContentType"/><Value Type="Text">'+$contenttype+'</Value></Eq></Where>'
$query=new-object Microsoft.SharePoint.SPQuery 
$query.ViewAttributes = "Scope='Recursive'"
$query.Query=$caml 
$items=$list.GetItems($query) 
# Pipe results to a loop and check out each element 
$items | % { $_.File.CheckOut() }
$items.Count
$items |  select Name
$web.Dispose()
$site.Dispose()

[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$weburl="http://records"
$contenttype="Court Document"
$site = new-object Microsoft.SharePoint.SPSite($weburl)
$web = $site.OpenWeb()
$list = $web.Lists["Claim / Litigation"]
$list | foreach {$_.Items|select Name, ContentType}
$caml='<Where><Eq><FieldRef Name="ContentType"/><Value Type="Text">'+$contenttype+'</Value></Eq></Where>'
$query=new-object Microsoft.SharePoint.SPQuery 
$query.ViewAttributes = "Scope='Recursive'"
$query.Query=$caml 
$items=$list.GetItems($query) 
# Pipe results to a loop and update each element 
$items | % { $_.Update() }
$items.Count
$items |  select Name
$web.Dispose()
$site.Dispose()

[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$weburl="http://records"
$contenttype="Court Document"
$site = new-object Microsoft.SharePoint.SPSite($weburl)
$web = $site.OpenWeb()
$list = $web.Lists["Claim / Litigation"]
$list | foreach {$_.Items|select Name, ContentType}
$caml='<Where><Eq><FieldRef Name="ContentType"/><Value Type="Text">'+$contenttype+'</Value></Eq></Where>'
$query=new-object Microsoft.SharePoint.SPQuery 
$query.ViewAttributes = "Scope='Recursive'"
$query.Query=$caml 
$items=$list.GetItems($query) 
# Pipe results to a loop and check in each element 
$items | % { $_.File.CheckIn("Script 3.0") }
$items.Count
$items |  select Name
$web.Dispose()
$site.Dispose()

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList