Create two addresses with the same prefix through PowerShell and Exchange Online

rektbyazure 20 Reputation points
2023-06-21T08:06:58.5233333+00:00

Hello,

I'm trying to create two addresses with the same prefix but different domains. Example:

******@domain1.com

******@domain2.com

I've done it successfully in the actual Exchange Online site for a tenant, where the emails in question are like that but the aliases for each address look like this (Automatically generated by the EXO site):

******@tenant.onmicrosoft.com

******@tenant.onmicrosoft.com

My question is if this is possible with the New-Mailbox command in PowerShell through the Exchange Online module and avoid the "A user with this name already exists. Use a different name" error in the console.

Thanks.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Aholic Liang-MSFT 13,886 Reputation points Microsoft External Staff
    2023-06-22T07:01:30.8266667+00:00

    Hi @ rektbyazure,

    Yes. You can use PowerShell to create mailboxes with the same prefix but different domains.

    However, when you create a mailbox with another domain name, it is not directly set as the primary SMTP address. Instead, the user principal name consists of Alias and the default domain.

    You can check it with the following command:

     Get-Mailbox "user | domain2" | select Name,Alias,UserPrincipalName
    

    Therefore, when you use PowerShell to create the second mailbox, you need to set the alias to be different from the previous mailbox, and then change its email address and alias.

    For detailed steps, you can refer to this link:

    Create shared mailbox with same alias - ALI TAJRAN

    (Note:Microsoft provides third-party contact information to help you find additional information about this topic. This contact information may change without notice. Microsoft does not guarantee the accuracy of third-party contact information.)


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.