The script updates a property of the target account based on the value of another property. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.
Parameters:
- $sourcePropertyName - Specifies the schema name of the property whose value will be used to pick the value for the property to update.
- $toSetPropertyName - Specifies the schema name of the property to update.
- $valueMap - maps values of the source property with values of the property to update.
- $pipelined - Specifies whether to pass the update through the Adaxes pipeline (e.g. to trigger business rules).
PowerShell
$sourcePropertyName = "title" # TODO: modify me
$toSetPropertyName = "department" # TODO: modify me
$valueMap = @{
"Account Specialist" = "Accounting"
"IT Specialist" = "IT"
} # TODO: modify me
$pipelined = $True # TODO: modify me
# Get user property value
try
{
$propertyValue = $Context.TargetObject.Get($sourcePropertyName)
}
catch
{
$Context.LogMessage("Property $sourcePropertyName is not specified for user %fullname%.", "Warning")
return
}
# Get property value
foreach ($item in $valueMap.GetEnumerator())
{
if ($item.Name -ne $propertyValue)
{
continue
}
$toSetPropertyValue = $item.Value
# Update the user
$user = $Context.BindToObjectByDNEx("%distinguishedName%", $pipelined)
$user.Put($toSetPropertyName, $toSetPropertyValue)
$user.SetInfo()
break
}