Hello,
We don't let addaxes update Azure like that.
Adaxes is aware of the way hybrid Exchange works. The action works accordignly.
I need to remove any spaces in the the email address due to a user having a space in their name like Del Rio for example.
In this case, it is easier to directly do the whole thing in a script like below. It will take the required template, remove spaces and add it as new address. In the script:
- $newAddressTemplate - Specifies the template for the address to add. You can use value references in the template. They will resolve into the corresponding property values of the target object.
- $setAsPrimary - Specifies whether to set the new address as primary.
$newAddressTemplate = "%firstname%%lastname%@example.com" # TODO: modify me
$setAsPrimary = $True
# Create an instance of the 'AdmExchangeMailboxParameters' class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"
# Automatically update e-mail addresses based on e-mail address policy
$mailboxParams.EmailAddressPolicyEnabled = $false
$emailAddresses = $mailboxParams.EmailAddresses
$emailAddresses.OverrideOldValues = $false
# Create a new e-mail address
$emailAddress = $emailAddresses.CreateAddress("ADM_EXCHANGE_ADDRTYPE_SMTP", $null)
$emailAddress.Address = $newAddressTemplate.Replace(" ","")
$emailAddress.IsPrimary = $setAsPrimary
# Add the new e-mail address to the existing list
$emailAddresses.Add("ADS_PROPERTY_APPEND", $emailAddress)
$mailboxParams.EmailAddresses = $emailAddresses
# Save changes
$user = $Context.BindToObjectByDNEx("%distinguishedName%", $true)
$user.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_RESOLVEVALUEREFERENCES")