Hybrid Management - Part 07 - Moving bulk mailboxes with PowerShell

Welcome to my tutorials on Hybrid Exchange - Office 365 Administration -

All Hybrid Administration Tutorials
- How to configure your desktop PC for Hybrid Exchange - Office 365 - Azure Administration - Link
- How to connect to Hybrid Exchange - Office 365 - Azure AD and Local AD via PowerShell - Link
- Hybrid Management - Part 01 - Creating local User mailboxes - Link
- Hybrid Management - Part 02 - Creating local Exchange Shared Mailboxes - Link
- Hybrid Management - Part 03 - Creating local Exchange Room and Equipment Mailboxes - Link
- Hybrid Management - Part 04 - Configure the Hybrid Connection Wizard - Link
- Hybrid Management - Part 05 - Individual mailbox moves via the EAC - Link
- Hybrid Management - Part 06 - Bulk mailbox moves via the EAC - Link
- Hybrid Management - Part 07 - Moving bulk mailboxes with PowerShell - Link
- Hybrid Management - Part 08 - Creating Office 365 User Mailboxes via PowerShell - Link
- Hybrid Management - Part 09 - Creating Office 365 Shared Mailboxes via PowerShell - Link
- Hybrid Management - Part 10 - Creating Office 365 Room and Equipment Mailboxes via PowerShell - Link


Hybrid Management - Part 07 - Moving bulk mailboxes with PowerShell

In this tutorial we will bulk migrate mailboxes with PowerShell from Exchange Local to Exchange Online. Bulk migrations via PowerShell are really quite simple with this script and csv file.
The script and file are available as part of my Hybrid Office 365 Administration Pack - Download Link

It is critical that you follow the pre-requisites below as my Hybrid connection script is needed to run these Hybrid Management scripts successfully.



Preparation Guides
- Follow the guides below to ensure your PC should is configured for Hybrid Administration - 
How to configure your desktop PC for Hybrid Exchange - Office 365 - Azure Administration - Link
How to connect to Hybrid Exchange - Office 365 - Azure AD and Local AD via PowerShell - Link

Downloads -
My Hybrid Office 365 Administration Pack - Download Link
My Hybrid Connection Script - Download Link


Introduction -

Everything you need to migrate local mailboxes to Exchange Online is built in to the services and you can save vast amounts of money by using the built in tools rather than purchase a third party tool for the migration. The process itself is fairly simple -
- Update my csv file with the mailboxes that are being migrated.
- Update my script with your environment details
- Run the script and wait patiently (it can take a LONG time to move large mailboxes.

This tutorial will purely focus on the technical aspect of moving the mailboxes via PowerShell while in a Hybrid state. If you are moving a large enterprise, the biggest challenge will be managing the migration itself.


Determining which local mailboxes are being moved -

Due to the way Exchange displays Local and Office 365 mailboxes, I always add the Database column to my Exchange views in the Local Exchange EAC. This assists me in quickly determining which mailboxes are local and which are Office 365. This option to add the Database column is not available in the Office 365 EAC.

From the Local Exchange EAC - in the images below, you can see which mailboxes are hosted locally and which are hosted in Office 365, by viewing the Database column. This is helpful as different pages have different displays.
- Mailboxes page
- Resources page
- Share Page

Mailboxes Page -
The EAC shows on the Mailboxes page, the mailbox type by default (User or Office 365).
It also shows Office 365 Resources (Equipment and Rooms)

Resources Page -
The EAC shows on the Resources page, only the LOCAL Resources.
As above, Office 365 Resources are displayed in the Mailboxes page.

Shared Page -
The EAC shows on the Shared page, ALL Shared mailboxes (both local Shared and Office 365 Shared).

Using the information above, I have created a list of local mailboxes that will be migrated from local to Office 365. This list will include two user mailboxes, one shared mailbox, one room and one equipment mailbox.


Preparation for moving mailboxes -

Editing the csv file with your Office 365 User Mailbox details

To start migrating local Exchange mailboxes to Office 365, ensure you have already downloaded the following scripts and csv folders mentioned earlier in the pre-requisites section.
--- Hybrid Connection Script - Download Link
--- Hybrid Office 365 Administration Pack - Download Link

Extract the folders in the Hybrid Office 365 Administration Pack zip file to the folder of your choice. Copy the appropriate ps1 and csv files to the root of c:\scripts.

Next we need to determine the SKU-IDs of your tenant. This information will be needed when assigning a license for your users. As this tutorial is created on a trial tenant, at this stage I only have one SKU-ID. In a real world production tenant, you may have many different licenses (and SKU-IDs displayed). The AccountSkuId is only used for LICENSED users. Every user that logs into Office 365 and accesses their personal mailbox will need a license.
Room, Equipment and Shared mailboxes do not need a license assigned.

Run the script - Get-SKUID.ps1 and copy the results to Notepad etc for future reference. The appropriate SKU-ID is needed for the spreadsheet, or your users will not be assigned licenses via the script.

As you can see in the image above, the AccountSkuId I need for assigning my E3 license is -

Edit the MailboxMove.csv with your data.
See the example below for guidance -

*** Notes for editing the MailboxMove.csv file ***
The following fields MUST contain data to create a valid mailbox -
- UPN                           (The UPN is needed to identify which mailboxes are migrating )
- UsageLocation          (This is the two digit country code for the appropriate country)
- AccountSkuID           (This is the APPROPRIATE license for the user)

*** Note - Leave the UsageLocation and AccountSkuID fields empty for accounts that do not need a license.

In the image above and below, I purposely left the fields empty on the equipment, room and shared mailboxes as they do not need licenses in Office 365.

Once you have finished creating your csv file, save as C:\Scripts\MailboxMove.csv

Note that if you would like to save the csv in a different location - you can easily edit the script variable as below.

Original script

Updated script with new csv location.


Updating the script variables with your Migration Endpoint and Tenant details

The script needs your migration endpoint details to enable a successful migration.
The Migration endpoint was discussed in Part 05 of the Hybrid Management tutorials - Link
The migration endpoint is usually the external FQDN of your on-premises Exchange.
Please see below for the migration endpoint I used in the earlier tutorial

I have previously determined that my migration endpoint matches the FQDN of my on-premises Exchange and is - mail.teamterry365.com

The second variable that is needed to be updated is your Tenant.

Note the red highlighted areas which contain the two variables that need to be edited and saved.

Now update the highlighted fields below with your environment details
$MigrationEndpoint = "mail.domain.com"
$Tenant = "tenant"

Example updated details for my test environment
$MigrationEndpoint = "mail.teamterry365.com"
$Tenant = "hybrid0617"

Save your updated connection script - New-MailboxMove-v-1-xx.ps1


Running the script for moving bulk mailboxes.

Connect to your local Exchange, AD and Azure AD Connect server using this tutorial -
- How to connect to Hybrid Exchange - Office 365 - Azure AD and Local AD via PowerShell - Link

Run the script -
Open PowerShell ISE and connect using my Hybrid Connection script - (see above).
Open the folder and drag the PowerShell file - New-MailboxMove-v-xxx.ps1 to ISE ready to run after you have updated the csv file.

Once you have updated your csv (as above), you can simply run the script by clicking the Play arrow.

Be Patient - This script takes a while to perform actions in the background.

You will eventually see a review of the mailbox moves that have started.
As you can see below, these mailboxes are empty, and in a real world migration, you would see larger mailbox size and archive mailbox sizes.

The script performs the following actions -
- Sets the User Location as per the csv file (empty field means no location)
- Assigns the license as per the csv file (empty field means no license)
- Moves the mailboxes to Office 365

Migration Notes -
The migration script options I have set are the minimum needed to perform an immediate cutover migration. To customise the migration options review the TechNet articles below.
New-MoveRequest - Link
Set-MoveRequest - Link

Scripting notes -
When managing your move requests and you are using my Office 365 Hybrid connection script, remember to add the prefixes to the cmdlets -
How to connect to Hybrid Exchange - Office 365 - Azure AD and Local AD via PowerShell - Link

To quickly check on the progress of your moves, run the cmd - get-EXOMoveRequest
*** The EXO prefix is needed when connecting with my Hybrid Connection script.


Confirming successful migrations.

As above, running the cmdlet - get-EXOMoveRequest will show if your mailboxes have completed successfully. You can also check the local and Office 365 EAC.

Local EAC will show that the User mailboxes now show as Office 365 mailboxes (red box).
Plus, the Equipment and Room mailbox that have moved will also show under Mailboxes

The Local EAC will show that the single Shared mailbox has also moved (no Database)

The Office 365 Admin portal - Users - Shows that User.104 and User.105 are now licensed -

The Office 365 EAC shows that mailboxes now exist in Office 365 for User.104 and User.105.

The Office 365 EAC also shows the recently moved Resources

The Office 365 EAC also shows the recently moved


Congratulations -
You have successfully moved bulk mailboxes via PowerShell


No comments:

Post a Comment