🔧 New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

Bulk Create Shared Mailboxes in Exchange Online via PowerShell (CSV Method)

When 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.


i) The Script: Bulk Shared Mailbox Creation via CSV

# 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)': $_"
    }
}
                            

Sample CSV Format (SharedMailboxes.csv)

Name,DisplayName,Alias
HRShared,HR Shared Mailbox,HRShared
FinanceShared,Finance Department Mailbox,FinanceDept
LegalShared,Legal Team Mailbox,LegalDept

ii) How the Script Works

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.

iii) Further Enhancements

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



iv) Possible Errors & Solutions

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)

Conclusion

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.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex