Process items in a Drop Off library using PowerShell

Everyone knows the Drop Off library in SharePoint, right? It routes documents to a final destination, based on rules you define.
This works OK for documents which are uploaded manually to the Drop Off library but I found out that it doesn’t work for documents which are uploaded with PowerShell (or any other method which uses the object model). Even if I fill in all required metadata and make sure the document it checked in… it still won’t leave the Drop Off library.

Seems that there’s a timer job in SharePoint (Content Organizer Processing) which runs daily and processes items which are left behind in Drop Off libraries. That’s great but what if you want to process that document immediately?

I found an article from Steve Lineberry which explains how to do this in C#. He used reflection to break open the timer job and found out that it was calling an internal method.

I needed this in PowerShell, so I did some translation and created a PowerShell function which does the same.

Function ProcessDropOffLibraryItem([Microsoft.SharePoint.SPWeb]$web, [Microsoft.SharePoint.SPListItem]$item, [bool]$listRequiresModeration)
{
   [Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRoutingWeb]$ECMDocumentRoutingWeb = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRoutingWeb($web)
   [System.Type]$type = $ECMDocumentRoutingWeb.GetType()
   [System.Reflection.BindingFlags]$flags = [System.Reflection.BindingFlags]::Instance –bor [System.Reflection.BindingFlags]::NonPublic
   $method = $type.GetMethod("ProcessWaitingFile", $flags)
   $objects = @()
   $objects += $item
   $objects += $listRequiresModeration
   try
   {
      $method.Invoke($ECMDocumentRoutingWeb, $objects)
   }
   catch
   {
      Write-Host "Unable to route document '$item.File.ServerRelativeUrl'."
   }
}

By Bart

Bart is a certified SharePoint consultant / architect at CTG Belgium NV with a broad professional experience in IT, a background in software development with a specialisation in Microsoft products and technologies and a solid knowledge and experience in Microsoft SharePoint Products and Technologies. He started as a COBOL developer on a mainframe environment and grew into software development for Windows platforms. Participated in projects varying from migrations of existing applications to development of Web applications and Windows applications. Became fascinated by the SharePoint 2007 platform and strongly believed in the added business value of this platform. Is since then fully committed to SharePoint and focuses on SharePoint implementations, migrations, integrations, design and coaching. Stays on top of new developments within the SharePoint technology stack and related technologies.