Script repository

Convert the first character of a property value to uppercase

Updated on: Jan 18, 2026, Views: 3261

Property validation

The script converts the first character of a property value to uppercase. If a value contains multiple parts separated by spaces, the first character of each part will be converted. To execute the script, create a business rule triggering Before creating a user or Before updating a user.

In the script, the $propertiesToCheck variable specifies names of the properties whose values will be updated by the script.

$propertiesToCheck = @("givenName", "sn", "name", "displayName") # TODO: modify me

function FixString ($string)
{
    return $string.SubString(0, 1).ToUpper() + $string.SubString(1).ToLower()
}

foreach ($propertyName in $propertiesToCheck)
{
    # Get property value.
    $value = $Context.GetModifiedPropertyValue($propertyName)
    if ([System.String]::IsNullOrEmpty($value))
    {
        continue
    }
   
    # Convert first value character to uppercase.
    if ($value -match " ")
    {
        $valueParts = $value.Split(" ") | %%{FixString $_}
        $value = [System.String]::Join(" ", $valueParts)
    }
    else
    {
        $value = FixString $value
    }
   
    # Update property
    $Context.SetModifiedPropertyValue($propertyName, $value)
}

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.