A shared mailbox in Microsoft 365 Exchange Online allows multiple users to access and manage emails, contacts, and calendar events from a single mailbox. It is commonly used by teams that need to collaborate on emails or manage customer queries. For example, a customer service team may use a shared mailbox to receive and respond to customer inquiries, where team members can access the mailbox simultaneously and work together to provide timely and consistent responses.
Using PowerShell to manage shared mailboxes provides more flexibility and control compared to the web-based Exchange Online Admin Center.
Some benefits of using PowerShell for managing shared mailboxes include:
In the following sections, we will provide a step-by-step guide on how to create, manage, and convert shared mailboxes using PowerShell, highlighting the benefits of using this tool for efficient management.
Before using PowerShell to manage shared mailboxes in Exchange Online, ensure that the following prerequisites are met:
Windows PowerShell or PowerShell Core: PowerShell is a command-line tool that comes pre-installed on Windows operating systems. If you are using a Windows device, you may already have PowerShell installed. Otherwise, you can download PowerShell from the Microsoft website. PowerShell Core is a cross-platform version of PowerShell that can run on Windows, Linux, and macOS. It can be downloaded from the PowerShell GitHub page.
Exchange Online PowerShell Module: To connect to Exchange Online PowerShell, you need to download and install the Exchange Online PowerShell module. This module contains the cmdlets (PowerShell commands) required to manage Exchange Online resources, including shared mailboxes. You can download the Exchange Online PowerShell module from the Microsoft website. Make sure that you have the latest version of the module installed before proceeding.
Azure AD Module for PowerShell: The Azure AD Module for PowerShell allows you to manage Azure Active Directory (AD) resources, such as user accounts and groups. It is required when managing some aspects of shared mailboxes, such as adding or removing members. You can download the Azure AD Module for PowerShell from the Microsoft website. Make sure that you have the latest version of the module installed before proceeding.
In the next section, we will discuss how to connect to Exchange Online PowerShell and Azure AD PowerShell using your Microsoft 365 admin account.
To connect to Exchange Online PowerShell and Azure AD PowerShell, follow these steps:
mathematicaInstall-Module -Name ExchangeOnlineManagement
sqlConnect-ExchangeOnline -UserPrincipalName admin@zylker.com
Replace "admin@zylker.com" with the user principal name (UPN) of your Microsoft 365 admin account.Once you're connected to Exchange Online PowerShell, you can use various cmdlets to manage shared mailboxes. Here are some common tasks and their corresponding PowerShell commands:
To create a shared mailbox, use the following PowerShell command:
powershellNew-Mailbox -Shared -Name "SharedMailboxName" -Alias "SharedMailboxAlias" -UserPrincipalName "SharedMailboxUPN" -DisplayName "Shared Mailbox Display Name" -PrimarySmtpAddress "shared@domain.com" -Password (ConvertTo-SecureString -String "Password" -AsPlainText -Force)
Replace the placeholders with the appropriate values:
"SharedMailboxName"
: The name of the shared mailbox."SharedMailboxAlias"
: The alias for the shared mailbox."SharedMailboxUPN"
: The User Principal Name (UPN) for the shared mailbox."Shared Mailbox Display Name"
: The display name of the shared mailbox."shared@domain.com"
: The primary SMTP address for the shared mailbox."Password"
: The password for the shared mailbox.To add members (users) to a shared mailbox, use the following PowerShell command:
powershellAdd-MailboxPermission -Identity "SharedMailboxName" -User "UserPrincipalName" -AccessRights FullAccess -InheritanceType All
Replace "SharedMailboxName"
with the name of the shared mailbox and "UserPrincipalName"
with the UPN of the user you want to add.
To remove members from a shared mailbox, use the following PowerShell command:
powershellRemove-MailboxPermission -Identity "SharedMailboxName" -User "UserPrincipalName" -AccessRights FullAccess -InheritanceType All
Replace "SharedMailboxName"
with the name of the shared mailbox and "UserPrincipalName"
with the UPN of the user you want to remove.
To convert an existing user mailbox to a shared mailbox, use the following PowerShell command:
powershellSet-Mailbox -Identity "UserMailboxUPN" -Type Shared
Replace "UserMailboxUPN"
with the UPN of the user mailbox you want to convert.
These are just a few examples of the PowerShell cmdlets available for managing shared mailboxes. You can explore additional cmdlets and their parameters in the Exchange Online PowerShell documentation.
Remember to save your PowerShell scripts for future use and documentation purposes. You can create reusable scripts to streamline the management of shared mailboxes.
PowerShell provides a powerful and efficient way to manage shared mailboxes in Microsoft 365 Exchange Online. By automating tasks, customizing settings, and leveraging the flexibility of PowerShell, you can effectively manage shared mailboxes for improved collaboration and productivity.
If you encounter any issues or require further assistance, refer to the Microsoft documentation or consult the Microsoft support team for guidance.