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.
PowerShell
$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()
}