I'musing this script to create Content Organizer Rules:
Add-PsSnapin Microsoft.Sharepoint.PowerShell
$mainURL = “https://*****”
$RecordCenterURL = “https://****“
[Microsoft.SharePoint.SPSite]$site = Get-SPSite $mainurl
[Microsoft.SharePoint.SPWeb]$web = Get-SPWeb $RecordCenterURL
$csv = Import-csv -path "C:\Scripts\Content Organiser Rules\ContentOrgRules.csv"
foreach($line in $csv)
{
$Name = $line.Name;
$ContentType = $line.ContentType;
$TargetPath = $line.TargetPath;
$a = " {0:hh:mm:ss}" -f (get-date)
write-host "Start @ $a" -f Cyan -nonewline;Write-Host ” – Creating the " -nonewline; write-host "$Name" -f Yellow -nonewline; write-host " Content Organizer Rule …” -NoNewline
[Microsoft.SharePoint.SPContentType]$ct = $site.RootWeb.ContentTypes[“$ContentType”]
[Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule]$rule = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule($web)
$rule.ConditionsString = ““
$rule.CustomRouter = “”
$rule.Name = “$Name Rule”
$rule.Description = “Routes ‘” + $ct.Name + “‘ documents to the records library”
$rule.ContentTypeString = $ct.Name
$rule.RouteToExternalLocation = $false
$rule.Priority = “5”
$rule.TargetPath = “$TargetPath”
$rule.Enabled = $true
$rule.Update()
$b = " {0:hh:mm:ss}" -f (get-date)
Write-Host -ForegroundColor GREEN “Done ”-nonewline;write-host "@ $b" -f cyan
Write-Host
}
$site.Dispose()
$web.Dispose()
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 6mins 10secs.Ive tried IISRESET, rebooting servers thinking its a build up of cache but its consistently taking 5 minutes 10 seconds to run. If there an underlining issue I'm not seeing?. at this rate it will take another 24+hours to create the rules I need.









