2

I have a bunch of doc libraries. I need to create content organizer rules for these 2000 libraries through powershell? Any help will be appreciated. I also have to fill the condition string.

2
  • Will you be running this PowerShell script on the server which has SharePoint?
    – Asad Refai
    Commented Aug 10, 2015 at 11:33
  • Yes the server has sharepoint 2010 installed.... Commented Aug 10, 2015 at 11:35

1 Answer 1

1

You can PowerShell script to create a content organizer rule. It uses Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule

[Microsoft.SharePoint.SPSite]$site = Get-SPSite http://www.mycompany.com
[Microsoft.SharePoint.SPWeb]$web = Get-SPWeb http://www.mycompany.com
[Microsoft.SharePoint.SPContentType]$ct = $site.RootWeb.ContentTypes["MyContentType"]
[Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule]$rule = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule($web)

$rule.Aliases = $ct.Name
$rule.ConditionsString = "<conditions></conditions>"
$rule.CustomRouter = ""
$rule.Name = $ct.Name
$rule.Description = "Routes '" + $ct.Name + "' documents to it's own library"
$rule.ContentTypeString = $ct.Name
$rule.RouteToExternalLocation = $false
$rule.Priority = "5"
$rule.TargetPath = $web.Lists["MyLibrary"].RootFolder.ServerRelativeUrl
$rule.Enabled = $true
$rule.Update()
8
  • I have the list of Doc libraries in a csv file for each of them i need to create a seperate org rule.how do i accomodate this? Commented Aug 10, 2015 at 11:42
  • Are those doc libraries in your Record Centre site?
    – Asad Refai
    Commented Aug 10, 2015 at 11:44
  • Ideal situation is: You have some Document libraries in your record centre site. And Content Organizer rule is the one which redirects the received documents from other site collections to the destination libraries based on Content Types. So My advice is you do not create rule for Doc Lib but for Content Types.
    – Asad Refai
    Commented Aug 10, 2015 at 11:47
  • yes... my url is something like this : myurl/rec/subsite/"the 2000 library names 1 by 1"/subfolder/subfolder. This is where the documents should route. That means i need to create 2000 diff org rules for each of these libraries Commented Aug 10, 2015 at 11:49
  • i want the library names to be dynamic from a csv as i want this powershell to run 2000 times for the 2000 diff library names Commented Aug 10, 2015 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.