The script converts the first value character of the specified properties to uppercase. If a value contains multiple parts separated by spaces, the first character of each part will be converted. The script can be used only in a business rule triggering Before creating a user or Before updating a user.
PowerShell
$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)
}