Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How can I set a Target Location folder based on unique value of property in Powershell?

$
0
0

I'm trying to build a Powershell script to automate the creation of all of my Document Routing rules within a record center in SharePoint 2013. I have all of the properties within the rule set, aside from the target location.

I don't want to set a static target location as each document processed by the Routing rules will be going to different folders based on their project (or PPM) ID. Here is the PS script I've currently have that does everything but the target location:

$configXMLPath = "C:\temp\ContentTypeListing.xml"

#store the config & global variables
$ctConfig = [xml](Get-Content $configXMLPath);
$RecordCenterURL = "http://spvm/sites/assessrc"
$web = Get-SPWeb $RecordCenterURL
$docLib = $web.Lists["Record Library"]
$conField = $docLib.Fields.GetField("Confidential Document")
$ppmField = $docLib.Fields.GetField("PPM ID")

#loop through each Content Type (Non-Confidential Rules)
foreach($xmlContentType in $ctConfig.ContentTypes.ContentType)
{
    #Write-Host "Creating rules for" $xmlProdFam.Name "..."
    #Create Rule
    [Microsoft.SharePoint.SPSite]$site = Get-SPSite $RecordCenterURL
    [Microsoft.SharePoint.SPWeb]$web = Get-SPWeb $RecordCenterURL
    [Microsoft.SharePoint.SPContentType]$ct = $site.RootWeb.ContentTypes[$xmlContentType]
    [Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule]$rule = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule($web)

    $rule.ConditionsString = "<Conditions><Condition Column='" + $conField.Id + "|ConfDoc|Confidential Document' Operator='IsEqual' Value='False'></Condition></Conditions>"
    $rule.CustomRouter = ""
    $rule.Name = "Non-Confidential " + $ct.Name + "Routing Rule"
    $rule.Description = "Routes '" + $ct.Name + "' documents from the '" + $xmlProdFam.Name + "' Product Family to the records library"
    $rule.ContentTypeString = $xmlContentType.Name
    $rule.RouteToExternalLocation = $false
    $rule.Priority = "5"
    $rule.TargetPath = ""
    $rule.enabled = $true
    $rule.Update()

}

Does anybody know how I can set the values in the screenshot below using Powershell? Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>