Tim Heeney, Sr. Program Manager, Microsoft Services

Marc Nivens, Sr. Escalation Engineer, Exchange Server Support

Lou Mandich, Sr. Premier Field Engineer, Microsoft Services

If you’ve completed a staged Exchange migration to migrate your organization’s Exchange 2007 on-premises mailboxes to Office 365 and you want to manage cloud-based users from your on-premises organization—using Active Directory—you should convert the on-premises mailboxes to mail-enabled users (MEUs). Why? Two things happen after a mailbox is migrated to the cloud in a staged Exchange migration:

  • A user has an on-premises mailbox and a cloud mailbox.
  • Mail sent to the user’s on-premises mailbox is forwarded to their cloud mailbox. This happens because during the migration process, the TargetAddress property on the on-premises mailbox is populated with the remote routing address of the cloud mailbox. So users need to connect to their cloud mailboxes to access their e-mail.

This behavior results in two issues:

  • If a person uses Microsoft Outlook to open their mailbox, the Autodiscover service still tries to connect to the on-premises mailbox, and the user won’t be able to connect to their cloud mailbox. If there are users that haven’t been migrated to the cloud, you can’t point your Autodiscover CNAME record to the cloud until all users are migrated.
  • If an organization decommissions Exchange after all on-premises mailboxes are migrated to the cloud, messaging-related user information on the cloud mailbox will be lost. The Microsoft Online Services Directory Synchronization tool (DirSync) removes data (such as proxy addresses) from the cloud mailbox object because the on-premises mailbox no longer exists and DirSync can’t match it to the corresponding cloud mailbox.

So, what is the best solution to resolve these issues? Convert the on-premises mailbox to a mail-enabled user (MEU) in your on-premises organization after the user’s mailbox has been migrated to the cloud. When you convert an on-premises mailbox to an MEU:

  • The proxy addresses from a cloud-based mailbox are copied to the new MEU; if you decommission Exchange, these proxy addresses are still retained in Active Directory.
  • The properties of the MEU enable DirSync to match the MEU with its corresponding cloud mailbox.
  • The Autodiscover service uses the MEU to connect Outlook to the cloud mailbox after the user creates a new Outlook profile.

We’ve provided a Windows PowerShell script that you can run to convert Exchange 2007 mailboxes to MEUs. When you run this script, the proxy addresses from the cloud-based mailbox are copied to the MEU, which resides in Active Directory. Also, the properties of the MEU enable DirSync to match the MEU with its corresponding cloud mailbox.

We’ve also provided a PowerShell script that collects information from the cloud-based mailboxes.

You can run both of these PowerShell script in the Exchange Management Shell in your on-premises Exchange organization.

Best Practice: It’s recommended that you convert on-premises mailboxes to MEUs for a migration batch. After a staged Exchange migration batch is finished and you have verified that all mailboxes in the batch are successfully migrated and the initial synchronization of mailbox items to the cloud is complete, convert the mailboxes in the migration batch to MEUs.

Downloading the scripts

There are scripts to help you convert mailboxes to MEUs. Click the following links to download the scripts.

  • ExportO365UserInfo.ps1   Collects information from your cloud mailboxes and saves it to a CSV file. The Exchange2007MBtoMEU.ps1 script uses the information in the CSV file to bulk-create the MEUs.
  • Exchange2007MBtoMEU.ps1   Coverts on-premises Exchange 2007 mailboxes to MEUs

What do the scripts do?

Here’s a brief description of what each script does.

ExportO365UserInfo.ps1

This is a Windows PowerShell script that collects information about the cloud mailboxes that you migrated during the staged Exchange migration. It uses a CSV file to scope the batch of users. It’s recommended that you use the same migration CSV file that you used to migrate a batch of users.

When you run the ExportO365UserInfo script:

  • The following properties are collected from the cloud mailboxes for the users listed in the input CSV file:
    • Primary SMTP address
    • Primary SMTP address of the corresponding on-premises mailbox
    • Other proxy addresses for the cloud mailbox
    • LegacyExchangeDN
    • msExchMailboxGuid
  • The collected properties are saved to a CSV file named Cloud.csv

Exchange2007MBtoMEU.ps1

This a PowerShell script that you run in your on-premises Exchange 2007 organization to convert mailboxes to MEUs. It uses the Cloud.csv file, which is output by the ExportO365UserInfo script.

When you run the Exchange2007MBtoMEU.ps1 script, it does the following for each mailbox listed in input CSV file:

  • Collects information from the input CSV file and from the on-premises mailbox.
  • Creates a list of proxy addresses from the on-premises and cloud mailbox to add to the MEU.
  • Deletes the on-premises mailbox.
  • Creates a MEU and populates the following properties:
    • legacyExchangeDN   Value from the on-premises mailbox.
    • mail   The primary SMTP of the cloud mailbox.
    • msExchMailboxGuid   Value from the cloud mailbox.
    • proxyAddresses   Values from both the on-premises mailbox and the cloud mailbox.
    • targetAddress    Read from the on-premises mailbox; the value is the primary SMTP of the cloud mailbox.

Steps to convert on-premises mailboxes to MEUs

1.    Copy ExportO365UserInfo.ps1, Exchange2007MBtoMEU.ps1, and the CSV file used to run the migration batch to the same directory in your on-premises organization.

2.    Rename the migration CSV file to migration.csv.

3.    In the Exchange Management Shell, run the following command. The script assumes that the CSV file is in the same directory and is named migration.csv.

    .\ExportO365UserInfo.ps1

You will be prompted to use the existing session or open a new session.

4.    Type n and press Enter to open a new session.

5.    Enter the administrator credentials for your cloud-based organization and then click OK.

        The script runs and then saves the Cloud.csv file to the current working directory.

6.    Run the following command in a new Exchange Management Shell session. This command assumes that ExportO365UserInfo.ps1 and Cloud.csv are located in the same directory.

    .\Exchange2007MBtoMEU.ps1 <FQDN of on-premises domain controller>

    Example:

    .\Exchange2007MBtoMEU.ps1 DC1.contoso.com

        The script converts on-premises mailboxes to MEUs for all users included in the Cloud.csv.

 7.    Verify that the new MEUs have been created. In Active Directory Users and Computers, do the following:

  1. Click Action > Find
  2. Click the Exchange tab
  3. Select Show only Exchange recipients, and then select Users with external email address
  4. Click Find Now

        The mailboxes that were converted to MEUs are listed under Search results.   

8.    Use Active Directory Users and Computers, ADSI Edit, or Ldp.exe to verify that the following MEU properties are populated with the correct information.

    • legacyExchangeDN
    • mail
    • msExchMailboxGuid
    • proxyAddresses
    • targetAddress