0 votes

After creating a new user I'm modifying the user and setting 2 proxy addresses.
I'm doing this with the build-in modify user functionality.

Our email format is %firstname%.%lastname%@domain1.com

End result looks like
SMTP:%firstname%.%lastname%@domain1.com
smtp:%firstname%.%lastname%@domain2.com

However these values can contain spaces which we don't want.
I've used the following script in the past which works but it doesn't work for the proxyAddresses field. Probably because it has multiple values.

$spacesRemoved = $False
# 
if ($Context.IsPropertyModified("ProxyAddresses"))
{
    $proxyAddresses = $Context.GetModifiedPropertyValue("ProxyAddresses")
    if ($proxyAddresses.Contains(" "))
    {
        # Remove spaces
        $proxyAddresses = $proxyAddresses.Replace(" ", "")
        # Update proxyAddresses
        $Context.SetModifiedPropertyValue("ProxyAddresses", $proxyAddresses)
        $spacesRemoved = $True
    }
}

# Log a message
if ($spacesRemoved)
{
    $Context.LogMessage("Spaces have been removed from the proxyAddresses",
        "Information")
}

So to clarify, we set multiple proxy addresses when creating a user.
Does anybody have an idea to get this working, i'm not as Powershell wizzard...

by (100 points)

1 Answer

0 votes
by (272k points)
selected by
Best answer

Hello,

As we understand, you are using the Modify Exchange properties action. In this case, the script will not work as it checks for a specific property modification. You need to use the below script in a Business Rule triggering Before Modifying Exchange properties of a User.

# Get Exchange properties set by the action
$modifiedMailboxParams = $Context.Action.MailParameters
if (-not($modifiedMailboxParams.EmailAddressesModificationEnabled))
{
    # E-mail addresses are not modified
    return
}

# Get the modified e-mail addresses
$modifiedAddressesCollection = $modifiedMailboxParams.EmailAddresses

for ($i = 0; $i -lt $modifiedAddressesCollection.Count; $i++)
{
    $operation = "ADS_PROPERTY_NONE"
    $modifiedEmailAddress = $modifiedAddressesCollection.GetAddress($i,[ref]$operation)
    $modifiedEmailAddress.Address = $modifiedEmailAddress.Address.Replace(" ", "")
}

$Context.Action.MailParameters = $modifiedMailboxParams
0

Thank you for your reply!
Your script works but I have one challenge with this.

I initially didn't use the "modify exchange property" because on the moment of creating a new user the mailbox has not been created yet in Office 365 (we only have O365 mailboxes, users are synced from on premise AD)
When adding the email addresses (modifying the exchange properties) it returns an error that the user does not have a mailbox yet.

If we would do this manually we just add email addresses in the proxyAddresses AD attribute (this is what Office 365 is using to determine the email addresses)

Let me know if you need more clarification

0

Hello,

Using the Modify Exchange properties action should work just fine if it is executed right after the action that assigns an Office 365 license with Exchange Online. In the Execution log, you will see a message stating that the mailbox is not created yet and Exchange properties will be updated later (i.e. when the mailbox is created). This behavior is by design. And the Business Rule we recommended will also work just fine in this case.

Is that what you saw in the Execution log? If not, could you provide us with a screenshot of the Business Rule and Execution log for it?

0

We are currently using group based licensing for O365 licensing.
This probably explains the different behavior.

We add the user to the "license group", this does mean that the license only gets assigned after the AD Connector sync.
We may have to consider going back to user based licensing and let Adaxes handle the assigning of licenses.

Or we need to delay the adding of email addresses until the mailbox has been created.

0

Hello,

The final solution will depend on your decision. Let us know how you decide to assign Office 365 licenses and we will provide you with detailed instructions.

0

Will Adaxes also support Microsoft 365, It's currently not listed as a license and we are slowly migrating from Office 365 E3 to Microsoft 365 E3

This has influence on the solution we are going for.

0

Hello,

As we understand, you do not see the license when assigning Office 365 licenses to users. If it was purchased after you configured Office 365 plans and services for your tenant in Adaxes, the plan is disabled. You need to enable it in the tenant settings. For details, see https://www.adaxes.com/help/?HowDoI.Per ... Plans.html.

0

My bad, I missed it.. the license is called SPE_E3.

We will be assigning the license with Adaxes.

Thanks you for the great support!!

Related questions

0 votes
1 answer

$property = "mail" # TODO: modify me #$regex = "^[a-zA-Z0-9_.%%\-\+]+@([a-zA-Z0-9_\-]+\.)+[a-zA-Z0-9_\-]+$" # TODO: modify ... regular expression: $regex") # TODO: modify me #} # Update property value $Context.SetModifiedPropertyValue($property, $value)

asked Feb 25, 2020 by Derek.Axe (480 points)
0 votes
1 answer

We have been able to add email addresses using the script in E-Mail Addresses Is there a way to reverse the process and specify the smtp address you want to remove using a similar subset of code.

asked Dec 14, 2022 by martin.mcclorey (40 points)
0 votes
1 answer

Greetings. When I create the parameters to make a business rule that looks for users whose Email Proxy Adresses does not contain 'SMTP:%userPrincipalName%', it still generates profiles ... and primary SMTP address don't match. Version is 2023 How rule is set

asked Dec 19, 2022 by MShep (80 points)
0 votes
1 answer

How do I go about modifying proxy addresses with PowerShell in Adaxes? Do you have an example in the script repository?

asked Jan 20, 2021 by ComputerHabit (790 points)
0 votes
1 answer

Hallo, In the deprovisioning process we add "_" to each email addresses like you see on below script: # Get mailbox parameters $mailboxParams = $Context.TargetObject.GetMailParameters( ... would like to remove those addresses, how can I do it using Adaxes SDK?

asked Aug 10, 2015 by axmaster (510 points)
3,348 questions
3,049 answers
7,791 comments
545,047 users