Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitWhen managing multiple shared mailboxes across departments, manual creation can be time-consuming. Instead, use a PowerShell script that reads input from a CSV file and creates shared mailboxes in Exchange Online in bulk — a must-have workflow for IT admins.
# Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com
# Import CSV file
$mailboxes = Import-Csv -Path "C:\MailboxInput\SharedMailboxes.csv"
# Loop through each entry and create shared mailboxes
foreach ($mb in $mailboxes) {
try {
New-Mailbox -Shared -Name $mb.Name -DisplayName $mb.DisplayName -Alias $mb.Alias
Write-Host "Created shared mailbox: $($mb.DisplayName)" -ForegroundColor Green
} catch {
Write-Warning "Failed to create mailbox '$($mb.DisplayName)': $_"
}
}
Name,DisplayName,Alias
HRShared,HR Shared Mailbox,HRShared
FinanceShared,Finance Department Mailbox,FinanceDept
LegalShared,Legal Team Mailbox,LegalDept
Step | Description |
1. Connect to Exchange | Uses Connect-ExchangeOnline to establish an admin session. |
2. Read CSV | Reads mailbox data from a structured CSV file using Import-Csv. |
3. Create Mailboxes | Iterates over each row and calls New-Mailbox -Shared with the provided values. |
4. Error Handling | Any creation failure is caught and logged to the console with Write-Warning. |
You can easily extend this script to:
Log output to a file:
Add-Content -Path "CreationLog.txt" -Value "Created: $($mb.DisplayName)"
🔐 Check for duplicates before creation:
if (-not (Get-Mailbox -Identity $mb.Alias -ErrorAction SilentlyContinue)) {
# Create mailbox
} else {
Write-Warning "Mailbox with alias $($mb.Alias) already exists."
}
Assign send-as permissions post-creation:
Add-MailboxPermission -Identity $mb.Alias -User "admin@yourdomain.com" -AccessRights FullAccess
Error Message | Cause | Solution |
---|---|---|
The term 'New-Mailbox' is not recognized | Exchange module not installed or session not connected | Run: Install-Module ExchangeOnlineManagement Connect-ExchangeOnline |
Alias already exists | Duplicate alias for another mailbox | Use unique Alias values in the CSV |
You don't have permission to perform this action | Insufficient role assignment | Assign the Recipient Management role via Exchange admin center |
File not found | Incorrect CSV path | Verify the path in the -Path parameter (e.g., C:\MailboxInput\SharedMailboxes.csv) |
The specified object is already a member | Duplicate add attempt | Add a pre-check to skip users already in the team (optional enhancement) |
This bulk creation script simplifies provisioning shared mailboxes in Exchange Online using Microsoft Exchange PowerShell. With just a structured CSV and a few lines of automation, IT teams can save time, reduce manual errors, and streamline mailbox creation across departments.
✅ Automating Shared Mailboxes Still not possible with Microsoft Graph PowerShell — so Exchange Online PowerShell remains the trusted choice for this task.
© m365corner.com. All Rights Reserved. Design by HTML Codex