Script repository

Copy property values from on-premises account to Entra one

Updated on: Jan 18, 2026, Views: 1971

User accounts

The script copies values of the specified properties from the target on-premises AD account to the corresponding Microsoft Entra account. To execute the script, create a business rule, custom commnad or scheduled task configured for the User object type.

In the scipt, the $propertiesToCopy variable specifies schema names of the properties whose values will be copied.

$propertiesToCopy = @("adm-CustomAttributeText1", "adm-CustomAttributeText2") # TODO: modify me

# Bind to the Entra account
try
{
    $entraId = $Context.TargetObject.Get("adm-AzureId")
}
catch
{
    $Context.LogMessage("User %fullname% has no Microsoft Entra identifier", "Information")
    return
}

try
{
    $entraAccount = $Context.BindToObject("Adaxes://<GUID=$entraId>")
}
catch
{
    $Context.LogMessage("User %fullname% has no Microsoft Entra account", "Information")
    return
}

# Update properties of Entra account
foreach ($propertyToCopy in $propertiesToCopy)
{
    try
    {
        $propertyValue = $Context.TargetObject.Get($propertyToCopy)
    }
    catch
    {
        continue
    }
    
    # Save the changes
    $entraAccount.Put($propertyToCopy, $propertyValue)
    $entraAccount.SetInfo()
}

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.