Script repository

Update property value based on the value of another property

Updated on: Jan 18, 2026, Views: 568

User accounts

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 - the schema name of the property whose value will be used to pick the value for the property to update.
  • $toSetPropertyName - 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).
$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
}

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.