Home About Tools Projects Guides & Blog ⚡ Hire Me ✦ Websites Contact →
☁️ M365 Admin

How to Manage Shared Mailboxes and Distribution Groups with PowerShell

Published 1 April 2025 · Updated March 2025

The Exchange admin centre covers the basics but PowerShell is much faster when you're working with multiple mailboxes, need to script recurring tasks, or want to make changes that the GUI doesn't expose. This guide covers the most common shared mailbox and distribution group tasks you'll run into day-to-day.

Connect to Exchange Online

PowerShell
# Install the module if you haven't already
Install-Module -Name ExchangeOnlineManagement -Force

# Connect - this opens a browser auth prompt
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

Shared Mailboxes

📬 Shared Mailboxes

Create a new shared mailbox

PowerShell
New-Mailbox -Shared -Name "IT Support" -DisplayName "IT Support" -Alias itsupport -PrimarySmtpAddress "itsupport@yourdomain.com"

Give a user Full Access to a shared mailbox

PowerShell
Add-MailboxPermission -Identity "itsupport@yourdomain.com" -User "jane@yourdomain.com" -AccessRights FullAccess -AutoMapping $true

# AutoMapping:$true makes the mailbox appear automatically in Outlook

Give Send As permission

PowerShell
Add-RecipientPermission -Identity "itsupport@yourdomain.com" -Trustee "jane@yourdomain.com" -AccessRights SendAs -Confirm:$false

Convert a regular mailbox to shared

This is useful when an employee leaves and you want to keep the mailbox accessible to their team without paying for an ongoing licence.

PowerShell
# Convert to shared first
Set-Mailbox -Identity "leaveruser@yourdomain.com" -Type Shared

# Then remove the licence from the account in Entra ID / M365 admin
# Shared mailboxes under 50GB don't need a licence
Remove the licence after converting
Once a mailbox is converted to shared and is under 50GB, it doesn't need a paid licence. Remove the M365 licence from the user account in the admin centre after converting to avoid the ongoing cost. The mailbox stays accessible to anyone with Full Access permission.

Hide a shared mailbox from the Global Address List

PowerShell
Set-Mailbox -Identity "itsupport@yourdomain.com" -HiddenFromAddressListsEnabled $true

Add a secondary email address (alias)

PowerShell
Set-Mailbox -Identity "itsupport@yourdomain.com" -EmailAddresses @{Add="it@yourdomain.com"}

Distribution Groups

📋 Distribution Groups

Create a distribution group

PowerShell
New-DistributionGroup -Name "All Staff" -Alias allstaff -PrimarySmtpAddress "allstaff@yourdomain.com" -MemberJoinRestriction Closed

Add members to a distribution group

PowerShell
Add-DistributionGroupMember -Identity "All Staff" -Member "jane@yourdomain.com"

# Add multiple from a CSV
Import-Csv "C:\users.csv" | ForEach-Object {{
    Add-DistributionGroupMember -Identity "All Staff" -Member $_.Email
}}

List all members of a group

PowerShell
Get-DistributionGroupMember -Identity "All Staff" | Select-Object Name, PrimarySmtpAddress

Allow external senders to email a distribution group

By default, distribution groups only accept mail from internal senders. To allow external email:

PowerShell
Set-DistributionGroup -Identity "All Staff" -RequireSenderAuthenticationEnabled $false
⚠️
Use Microsoft 365 Groups instead for modern collaboration
Classic distribution groups only handle email. Microsoft 365 Groups (also known as Unified Groups) include a shared mailbox, SharePoint site, Teams channel, and Planner board. For new groups where collaboration matters, M365 Groups are the better choice. You can create them with New-UnifiedGroup in PowerShell.
J
Jack Davies
IT Engineer · M365 & Intune Specialist

Jack is an IT Technical Engineer based in the UK, working day-to-day with Microsoft 365, Intune, and Entra ID across a range of businesses. He holds the MS-900 certification and is studying for a BSc in Cyber Security through the Open University. Outside of work he builds and documents home lab projects, writes guides on this site, and takes on M365 consulting work for small businesses.

About Jack → LinkedIn →
// monthly tips

Get M365 tips in your inbox

Practical Intune and Microsoft 365 tips, once a month. No spam, no fluff.