0 votes

Hello Support Team

We are looking to change our email address format to first.last@company.com. We have some newer users using the new format but we never backfilled the existing users. How would we systematically add a secondary email address (NOT set to primary) to each account and deal with the possibility of duplicates?

by (3.2k points)
0

Hello,

Could you specify whether it has to be done for on-premise mailboxes, Office 365 mailboxes or both?

0

This would be for on premise only at this time.

0

Hello,

Do we understand correctly that you actually have a hybrid environment, but the update should be done only for on-premise mailboxes?

0

We are prepping for an hybrid environment. Today is onprem exchange only.

1 Answer

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

Hello,

Thank you for clarifying, you need to create a Scheduled Task like the following:

For information on how to create Scheduled Tasks, have a look at the following tutorial: https://www.adaxes.com/tutorials_Automa ... gement.htm.

0

Thank you for the quick response. We will test.

One question will this just fail if a email address is already named the same? We would want it to do what we currently do and randomize a two digit number after the lastname.

0

Hello,

If the user has the primary or secondary address email set to firstname.lastname@company.com, the task will not affect the user at all. If you need a different behavior, specify all the possible details and we will provide detailed instructions.

0

We need the script to check and verify the desired email address of firstname.lastname@company.com is available and if not randomize 2 digits to the end of the lastname.

0

Hello,

Thank you for clarifying. You need to use the below script and a Scheduled Task configured for User Object type. The task needs to be executed just once.

$addressToAdd = "%firstname%.%lastname%@company.com" # TODO: modify me

function IsAddressUnique($value)
{
    $searcher = $Context.BindToObject("Adaxes://rootDSE")
    $searcher.SearchFilter = "(&(sAMAccountType=805306368)(proxyAddresses=smtp:$value))"
    $searcher.SearchScope = "ADS_SCOPE_SUBTREE"
    $searcher.PageSize = 500
    $searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
    $searcher.SetPropertiesToLoad($properties)
    $searcher.SizeLimit = 1
    $searcher.VirtualRoot = $True

    try
    {
        $searchResultIterator = $searcher.ExecuteSearch()
        $searchResults = $searchResultIterator.FetchAll()

        return $searchResults.Length -eq 0
    }
    finally
    {
        # Release resources
        if ($searchResultIterator){ $searchResultIterator.Dispose() }
    }
}

function AddNewEmailAddress($addressToAdd, $mailboxParams)
{
    $emailAddresses = $mailboxParams.EmailAddresses

    # Create a new e-mail address
    $emailAddress = $emailAddresses.CreateAddress("ADM_EXCHANGE_ADDRTYPE_SMTP", $null)
    $emailAddress.Address = $addressToAdd
    $emailAddress.IsPrimary = $False

    # Add the new e-mail address to the existing list
    $emailAddresses.Add("ADS_PROPERTY_APPEND", $emailAddress)
    $emailAddresses.OverrideOldValues = $False
    $mailboxParams.EmailAddresses = $emailAddresses

    $Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
}

if ($Context.TargetObject.RecipientType -ne "ADM_EXCHANGERECIPIENTTYPE_MAILBOXENABLED")
{
    return
}

$mailboxParams = $Context.TargetObject.GetMailParameters()
foreach ($emailAddress in $mailboxParams.EmailAddresses.GetAddressesByPrefix("smtp"))
{
    if ($emailAddress.Address -eq $addressToAdd)
    {
        return
    }
}

# Add new address
if (IsAddressUnique $addressToAdd)
{
    AddNewEmailAddress $addressToAdd $mailboxParams
    return
}

$addressParts = $addressToAdd.Split("@")
$addressFirstPart = $addressParts[0]
$addressDomainPart = $addressParts[1]
for ($i = 1; $i -le 100; $i++)
{
    $uniqueEmailAddress = $addressFirstPart + $i.ToString("00") + "@$addressDomainPart"
    if (IsAddressUnique $uniqueEmailAddress)
    {
        AddNewEmailAddress $uniqueEmailAddress $mailboxParams
        return
    }
}

For information on how to create Scheduled Tasks, have a look at the following tutorial: https://www.adaxes.com/tutorials_Automa ... gement.htm.

Related questions

0 votes
1 answer

We recently added another domain to our environment, when we use the script to create users from a CSV file they are all being created in the first domain instead of the ... password for user '$displayName'. Error: " + $_.Exception.Message, "Warning") } }

asked Nov 1, 2017 by willy-wally (3.2k points)
0 votes
1 answer

Hello, I search an ldap filter to allow me to show managed user and user managed by the managed user (dunno if i'm clear). Let me ... ((manager=%distinguishedName%).distinguishedname))) (|(manager=%distinguishedName%)(manager=$(manager=%distinguishedName%))

asked May 24, 2016 by Alexandre (460 points)
0 votes
1 answer

We will be adding email aliases to the proxyaddresses attribute in order to track our Google Apps mailbox aliases (no Exchange here). I currently have a script that Support helped ... is already in use. Please verify that account is not being duplicated"); } }

asked Dec 10, 2014 by jiambor (1.2k points)
0 votes
1 answer

Hello, I'm wondering if it's possible to export a list of all users in AD along with their email addresses to an Excel spreadsheet and then schedule that export to append ... address that wasn't previously used. Please let me know if this is possible. Thanks!

asked Apr 11 by sjjb2024 (60 points)
0 votes
1 answer

The default pattern format we need should be :First letter of User firstname concatinated to user lastname and pd.sandiego.gov as in jdoe@pd.sandiego.gov

asked Jan 23 by hhsmith (40 points)
3,349 questions
3,050 answers
7,791 comments
545,066 users