Create Record Center Content Organizer rules using Powershell


Here is how to Create a Record Center Sub Site , and add a Content Organizer rule to it.

First, We need to Create the Subsite.  The Template “OFFILE#1” is the Template for Record Center.  You can find all Sharepoint Templates here.

$mainURL = “http://vlad.test.loc”

$RecordCenterURL = “http://vlad.test.loc/RecordCenter“

$web = New-SPWeb $RecordCenterURL -Template “OFFILE#1”   -AddToTopNav

Now, here is the chunk of code to Create the Content Organizer Rule.

Write-Host -ForegroundColor White ” – Creating the Supporting Documents  Content Organizer Rule …” -NoNewline

 [Microsoft.SharePoint.SPSite]$site = Get-SPSite $mainurl

[Microsoft.SharePoint.SPWeb]$web = Get-SPWeb $RecordCenterURL

[Microsoft.SharePoint.SPContentType]$ct = $site.RootWeb.ContentTypes[“Document”]

[Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule]$rule = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule($web)

$rule.ConditionsString = “

$rule.CustomRouter = “”

$rule.Name = “Supporting Documents Rule”

$rule.Description = “Routes ‘” + $ct.Name + “‘ documents to the records library”

$rule.ContentTypeString = $ct.Name

$rule.RouteToExternalLocation = $false

$rule.Priority = “5”

$rule.TargetPath = “/Records/Records”

$rule.Enabled = $true


Write-Host -ForegroundColor GREEN “Done.”


As you can see, this rule routes the Content Type “Document” to the /Records/Records Library. 

Previous Post
Create a SharePoint Site Collection with a custom Template using Powershell
Next Post
Change Sharepoint Site Collection Logo with Powershell Tutorial


  • December 11, 2015 at 8:48 pm

    I am using a variation on this script posted here my script pulls from a CSV file because I have over 600 rules to add. The script works and the rules work, however as I add more and more rules the time to create them increased, from 10-15 seconds to 5mins 10secs.

    Ive tried IISRESET, rebooting servers thinking its a build up of cache but its taking 5 minutes 10 seconds to run the 7minutes and it seems to get worse as I add more. If there an underlining issue im not seeing?. at this rate it will take another 48+hours to create the rules I need.

    • December 13, 2015 at 12:51 pm

      This is sometimes an issue with all the PowerShell scripts. Try splitting them into maybe 10 files of 60 “rules”. Let me know if it worked!

      • December 13, 2015 at 5:45 pm

        Thanks for the reply, I did end up splitting them into batches of 60-70 but it would get progressively worse, At its peak it took 30 minutes per rule then when it reached the last two rules it took seconds….weird behaviour. I did notice some ULS logs complaining about Slow SQL Queries, but I’ve never been able to find more details in SQL.

Leave a Reply

15 49.0138 8.38624 1 0 4000 1 300 1