skip to Main Content

Bulk create Office 365 mailboxes in Exchange hybrid

How to bulk create Office 365 mailboxes for existing AD users in Exchange hybrid configuration? Good to know is that creating mailboxes in Exchange hybrid need to be run from Exchange on-premises. You can run a command to create an Office 365 mailbox for an existing AD user. But what if you want to create an Office 365 mailbox for a list of users?

Before you start to bulk create Office 365 mailboxes

In a previous article, we explained how to create an Office 365 mailbox in Exchange Hybrid configuration. Please have a read through it, as it will simplify the below process.

You will understand how to:

  • Create Office 365 mailboxes
  • Test hybrid mail flow in both organizations
  • Test GAL visibility in both organizations.

After you read the above, let’s jump right into the first step.

Existing AD users

In the organization, we make use of templates. We copy that template and create new users. In this example, there are four AD users created without a mailbox. The users are present in the Organizational Unit Finance.

Add the Exchange Online license to the user. In our example, we will make the user member of the security group that contains the Exchange Online license. That’s because we have set up Azure group-based licensing. You don’t have to assign an EXO (Exchange Online) license right now, and it’s fine to do that at a later stage.

Remember that you can’t send and receive an email if you don’t have an EXO license.

Open one of the user properties and verify the account details.

Bulk create Office 365 mailboxes in Exchange hybrid configuration AD user properties

Create CSV file

Create a CSV file with the user’s SamAccountName. Copy the same as below.

Bulk create Office 365 mailboxes in Exchange hybrid configuration CSV users

Save the CSV file in C:\temp.

Bulk create Office 365 mailboxes in Exchange hybrid configuration temp

Bulk create Office 365 mailbox

Run Exchange Management Shell as administrator in the on-premises organization. Import the file EnableRemoteMailbox.csv that you did create earlier.

[PS] C:\>$Users = Import-Csv C:\Temp\EnableRemoteMailbox.csv

Verify that you get the CSV input when you enter the $Users variable.

[PS] C:\>$Users

SamAccountName
--------------
Joshua.Hunter
Peter.Campbell
Sophie.Ferguson
Fiona.Marshall

Create Exchange Online mailbox for existing users in local AD. Make use of the Enable-RemoteMailbox cmdlet. Change the tenant information to yours. In this example, it’s exoip365.mail.onmicrosoft.com.

The proxy address will always be @tenant.mail.onmicrosoft.com.

The output shows the mailbox creation.

[PS] C:\>$Users | ForEach-Object {Enable-RemoteMailbox $_.SamAccountName -RemoteRoutingAddress ($_.SamAccountName+'@exoip365.mail.onmicrosoft.com')}

Name                     RecipientTypeDetails        RemoteRecipientType
----                     --------------------        -------------------
Joshua.Hunter            RemoteUserMailbox           ProvisionMailbox
Peter Campbell           RemoteUserMailbox           ProvisionMailbox
Sophie Ferguson          RemoteUserMailbox           ProvisionMailbox
Fiona Marshall           RemoteUserMailbox           ProvisionMailbox

Do you get an ExchangeGuid is mandatory on UserMailbox error after runing the above command? Read the article: Enable-RemoteMailbox ExchangeGuid is mandatory on UserMailbox.

Force Azure AD connect to sync

Wait for the Azure Active Directory synchronization or force sync Azure AD connect with PowerShell.

PS C:\> Start-ADSyncSyncCycle -PolicyType Initial 

Verify Office 365 mailboxes

Always great to verify your work.

[PS] C:\>$Users | ForEach-Object {Get-RemoteMailbox -Identity $_.SamAccountName} | ft Name,PrimarySmtpAddress,RecipientType*,Remote*

Name            PrimarySmtpAddress        RecipientType RecipientTypeDetails RemoteRoutingAddress                               RemoteRecipientType
----            ------------------        ------------- -------------------- --------------------                               -------------------
Joshua Hunter   Joshua.Hunter@exoip.com        MailUser    RemoteUserMailbox SMTP:Joshua.Hunter@exoip365.mail.onmicrosoft.com      ProvisionMailbox
Peter Campbell  Peter.Campbell@exoip.com       MailUser    RemoteUserMailbox SMTP:Peter.Campbell@exoip365.mail.onmicrosoft.com     ProvisionMailbox
Sophie Ferguson Sophie.Ferguson@exoip.com      MailUser    RemoteUserMailbox SMTP:Sophie.Ferguson@exoip365.mail.onmicrosoft.com    ProvisionMailbox
Fiona Marshall  Fiona.Marshall@exoip.com       MailUser    RemoteUserMailbox SMTP:Fiona.Marshall@exoip365.mail.onmicrosoft.com     ProvisionMailbox

Verify in the on-premises Exchange admin center that the mailbox type will show Office 365. If you have a mailbox on-premises, it’s the mailbox type User.

Bulk create Office 365 mailboxes in Exchange hybrid configuration on premises EAC

Double-click on a user and click in the menu on email address. You will see:

  1. A smtp with <user>@tenant.mail.onmicrosoft.com.
  2. The remote routing address <user>@tenant.mail.onmicrosoft.com.
Bulk create Office 365 mailboxes in Exchange hybrid configuration on premises email address

Go back to the Exchange admin center and click in the top bar on Office 365. Log in with your Microsoft 365 admin credentials.

You will only see Office 365 mailboxes in Microsoft 365 Exchange admin center. The on-premises mailboxes are not shown on Microsoft’s cloud servers.
Bulk create Office 365 mailboxes in Exchange hybrid configuration Office 365 EAC

Double-click on a user and click on email address. There is no remote routing address option in the cloud, and you will see two smtp onmicrosoft.com email addresses:

  1. smtp:<user>@tenant.mail.onmicrosoft.com
  2. smtp:<user>@tenant.onmicrosoft.com
Bulk create Office 365 mailboxes in Exchange hybrid configuration Office 365 email address

Looks great! Did this help you to bulk create Office 365 mailboxes for existing AD users?

Read more: Get users that have Out of Office enabled in Exchange »

Conclusion

In this article, you learned how to bulk create Office 365 mailboxes in Exchange hybrid configuration. It’s important that you create mailboxes from the on-premises environment. Create a CSV file with the user’s SamAccountName and run the commands as shown in Exchange Management Shell. As of last, double-check and verify that the mailboxes are created.

Did you enjoy this article? You may also like List mailboxes in Exchange database with PowerShell. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top