Exchange Online is Microsoft’s cloud messaging service offering email, calendar and contacts features.
Installation and connection
Action PowerShell Command Install Exchange module Install-Module -Name ExchangeOnlineManagement -ForceConnect Connect-ExchangeOnlineConnect (MFA) Connect-ExchangeOnline -UserPrincipalName [email protected] Verify connection Get-OrganizationConfigDisconnect Disconnect-ExchangeOnline -Confirm:$false
Mailbox management
Mailbox types
Type License Required Usage User Office 365/M365 Personal mailbox Shared None Team, department Resource - Room Exchange Online Plan 1 Room booking Resource - Equipment Exchange Online Plan 1 Shared equipment
Action Command List all mailboxes Get-Mailbox -ResultSize UnlimitedSearch mailbox Get-Mailbox -Identity "[email protected] "Create user mailbox New-Mailbox -Name "John Doe" -UserPrincipalName "[email protected] " -FirstName "John" -LastName "Doe"Create shared mailbox New-Mailbox -Name "Support" -PrimarySmtpAddress "[email protected] " -SharedCreate resource mailbox New-Mailbox -Name "Meeting Room A" -Room -PrimarySmtpAddress "[email protected] "Modify display name Set-Mailbox -Identity "[email protected] " -DisplayName "John Doe - IT"Delete mailbox Remove-Mailbox -Identity "[email protected] " -Confirm:$falseDisable mailbox Set-Mailbox -Identity "[email protected] " -AccountDisabled:$true
Distribution groups
Exchange group types
Type Characteristics Usage Distribution List (DL) Static list, manual management Teams, departments Dynamic Distribution List (DDL) Based on automatic AD criteria All managers, new employees Security Group Can be used for permissions SharePoint access + distribution Office 365 Group Integrated SharePoint/Teams Full collaboration
Action Command List all groups Get-DistributionGroup -ResultSize UnlimitedCreate distribution group New-DistributionGroup -Name "IT Team" -PrimarySmtpAddress "[email protected] "Create dynamic list New-DynamicDistributionGroup -Name "All IT" -Filter "Department -eq 'IT'"Add member Add-DistributionGroupMember -Identity "IT Team" -Member "[email protected] "Remove member Remove-DistributionGroupMember -Identity "IT Team" -Member "[email protected] "View members Get-DistributionGroupMember -Identity "IT Team"Modify description Set-DistributionGroup -Identity "IT Team" -Notes "Main IT team"Delete group Remove-DistributionGroup -Identity "IT Team" -Confirm:$false
Permissions and delegations
Permission types
Permission Access Typical usage FullAccess Full read/write Assistant, backup SendAs Send as owner Official communication SendOnBehalf Send on behalf of Visible delegation ReadPermission Read only Audit, consultation
Quotas and storage
Action Command View mailbox quota Get-Mailbox -Identity "[email protected] " | Select ProhibitSendQuota,ProhibitSendReceiveQuotaModify user quota Set-Mailbox -Identity "[email protected] " -ProhibitSendQuota 90GB -ProhibitSendReceiveQuota 100GBView storage usage Get-MailboxStatistics -Identity "[email protected] " | Select DisplayName,TotalItemSize,ItemCountTop 10 largest mailboxes Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort TotalItemSize -Descending | Select -First 10 DisplayName,TotalItemSize
Storage limits by license
License Standard Quota Archiving Additional Cost Exchange Online Plan 1 50 GB Optional Archiving +/month Office 365 E3 100 GB Included unlimited - Office 365 E5 100 GB Included unlimited - Shared Mailbox 50 GB free -> 100GB with E3 license Available with license -
Export and management scripts
Export mailbox list
# Complete export with statistics
$mailboxes = Get-Mailbox - ResultSize Unlimited
$results = foreach ($mailbox in $mailboxes) {
$stats = Get-MailboxStatistics - Identity $mailbox.UserPrincipalName
[ PSCustomObject ] @ {
DisplayName = $mailbox.DisplayName
UserPrincipalName = $mailbox.UserPrincipalName
MailboxType = $mailbox.RecipientTypeDetails
TotalSize = $stats.TotalItemSize
ItemCount = $stats.ItemCount
LastLogon = $stats.LastLogonTime
ProhibitSendQuota = $mailbox.ProhibitSendQuota
}
}
$results | Export-Csv - Path " C:\temp\ExchangeMailboxes.csv " - NoTypeInformation - Encoding UTF8
Export distribution groups and members
# Detailed DL groups export
$groups = Get-DistributionGroup - ResultSize Unlimited
$results = foreach ($group in $groups) {
$members = Get-DistributionGroupMember - Identity $group.Identity
foreach ($member in $members) {
[ PSCustomObject ] @ {
GroupName = $group.DisplayName
GroupEmail = $group.PrimarySmtpAddress
MemberName = $member.DisplayName
MemberEmail = $member.PrimarySmtpAddress
MemberType = $member.RecipientTypeDetails
}
}
}
$results | Export-Csv - Path " C:\temp\DistributionGroups.csv " - NoTypeInformation - Encoding UTF8
Bulk mailbox creation via CSV
# CSV format: DisplayName,UserPrincipalName,FirstName,LastName,Department
$users = Import-Csv - Path " C:\temp\NewMailboxes.csv " - Delimiter " ; "
foreach ($user in $users) {
try {
New-Mailbox - Name $user.DisplayName `
- UserPrincipalName $user.UserPrincipalName `
- FirstName $user.FirstName `
- LastName $user.LastName `
- Department $user.Department
Write-Host " Mailbox created: $ ( $user.DisplayName ) " - ForegroundColor Green
} catch {
Write-Host " Error creating $ ( $user.DisplayName ) : $ ( $_ .Exception.Message ) " - ForegroundColor Red
}
}
Bulk add members to DL groups
# CSV format: GroupName,MemberEmail
$members = Import-Csv - Path " C:\temp\GroupMembers.csv " - Delimiter " ; "
foreach ($member in $members) {
try {
Add-DistributionGroupMember - Identity $member.GroupName - Member $member.MemberEmail
Write-Host " Added $ ( $member.MemberEmail ) to $ ( $member.GroupName ) " - ForegroundColor Green
} catch {
Write-Host " Error adding $ ( $member.MemberEmail ) : $ ( $_ .Exception.Message ) " - ForegroundColor Red
}
}
Common troubleshooting
Problem Solution Emails not delivered Check Get-MessageTrace, transport rules, quotas Shared mailbox access denied Check permissions, automapping, Outlook cache Slow synchronization Force AD sync: Start-ADSyncSyncCycle -PolicyType Delta Mobile no longer receiving Reset partnership: Remove-MobileDevice then reconnect Quota exceeded Check Get-MailboxStatistics, enable archiving