Did you start a migration from Exchange on-Premises to Exchange Online in batches? If you…
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?
Table of contents
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.
Note: 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.
Create CSV file
Create a CSV file with the user’s SamAccountName. Copy the same as below.
Save the CSV file in C:\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.
Note: 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 Delta
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.
Double-click on a user and click in the menu on email address. You will see:
- A smtp with <user>@tenant.mail.onmicrosoft.com.
- The remote routing address <user>@tenant.mail.onmicrosoft.com.
Go back to the Exchange admin center and click in the top bar on Office 365. Sign in with your Microsoft 365 admin credentials.
Note: 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.
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:
- smtp:<user>@tenant.mail.onmicrosoft.com
- smtp:<user>@tenant.onmicrosoft.com
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.
Hi Ali,
Thank you for this useful article..
After the creation of bulk mailboxes (in most cases where users are Consultants), there’s a need to the email addresses of each of them to accomodate firstname.lastname.EXT@domain.com
Right now, we disable the email policy and edit the Primary mail address to add in the .EXT to them..
is there a way to do this in bulk via such a script? Would be really helpful
Thanks,
Santosh