This script pre-processes Microsoft 365 / Exchange Online mailbox export CSVs to ensure 100% resolution when scanning Shared Mailboxes in the Google Workspace Migration Planner.
Before running this script in a environment, ensure you have:
- PowerShell 7+ (Recommended) or PowerShell 5.1 on Windows/macOS/Linux.
- ExchangeOnlineManagement Module (v3.0.0 or later):
Install-Module -Name ExchangeOnlineManagement -AllowClobber -Force
The admin account running the script must have at least one of the following roles in Exchange Online:
- Global Reader
- Exchange Administrator
- View-Only Recipients
Obtain the list of shared mailboxes.
- The CSV can contain any standard header name for emails (
Email Id,Email,PrimarySmtpAddress,UserPrincipalName,Identity, orEmailAddress). - Example
input.csv:Email Id sales@company.com support-alias@company.com info-shared@tenant.onmicrosoft.com
-
Open PowerShell and navigate to or run
UPN_SHaredMailboxes.ps1:.\UPN_SHaredMailboxes.ps1
-
Authenticate with Exchange Online:
- If not already connected, an interactive M365 sign-in prompt will open. Log in using an account with appropriate Exchange Online read permissions.
-
Provide Input File Path:
- When prompted:
Enter the path to your input CSV file (e.g., C:\Migration\input.csv): - Drag and drop the CSV file into the terminal window or type the full file path.
- When prompted:
The script will perform the following steps automatically:
- Pre-fetch: Downloads tenant mailbox data in a single batch.
- Hashtable Mapping: Maps every primary email, UPN, and alias to its respective Exchange Online mailbox object.
- Instant Lookup: Resolves all input rows in seconds without incurring Graph API throttling.
Sample Output:
Connecting to Exchange Online...
Successfully loaded 1808 entries from CSV.
Using column 'Email Id' for Exchange Online lookup...
Processing... Please wait.
Pre-fetching Exchange Online mailboxes into memory...
Loaded 4250 email address/alias mappings from Exchange Online.
============================================================
PROCESSING COMPLETE
============================================================
Total Input Rows : 1808
Successfully Resolved : 1808
Shared Mailboxes Found : 1750
User Mailboxes / Other : 58
Not Found / Skipped : 0
============================================================
OUTPUT FILES GENERATED:
1. Migration Planner CSV : C:\Migration\MigrationPlanner_SharedMailboxes_UPN.csv
2. Full Audit Report : C:\Migration\ExchangeOnline_Full_Audit_Report.csv
- Open the Google Workspace Migration Planner tool.
- Navigate to the Shared Mailboxes scan/discovery section.
- Upload
MigrationPlanner_SharedMailboxes_UPN.csvgenerated by the script. - Result: The Migration Planner will resolve 100% of valid shared mailboxes without dropping entries or failing on alias mismatches.
| File Name | Description | Purpose |
|---|---|---|
MigrationPlanner_SharedMailboxes_UPN.csv |
Clean CSV containing single column Email Id populated only with exact Entra ID UPNs of verified SharedMailbox accounts. |
Feed directly into Google Workspace Migration Planner. |
ExchangeOnline_Full_Audit_Report.csv |
Comprehensive diagnostic report containing Input Email, UserPrincipalName, PrimarySmtpAddress, RecipientType, and Status. |
Use for review, identifying non-shared mailboxes (e.g. UserMailbox), or investigating missing accounts. |
- Module not found: If
Connect-ExchangeOnlinefails, runInstall-Module ExchangeOnlineManagement -Force. - Not Found / Skipped Entries: Check
ExchangeOnline_Full_Audit_Report.csvfor any rows markedNOT_FOUNDto verify if accounts were deleted or misspelled in the CSV. - UserMailbox in Shared Scan: If regular user accounts are included, they will be listed as
UserMailboxin the audit report and automatically excluded from the Migration Planner output CSV.