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
Write-Host "Unable to route document '$item.File.ServerRelativeUrl'."