In this blog post, I’m going to show you how to create a shared mailbox in Exchange online using PowerShell.
The procedure is pretty well detailed in Microsoft documentation, but it can also be confusing and time-consuming when you just need straightforward instructions. Therefore, I write this tutorial mainly for my future self and I hope you guys will find it useful too.
Let’s assume that you’re the IT administrator for a multinational business named
Contoso corporation. And you've been requested to create a shared mailbox (
email@example.com) for the Marketing department. That mailbox will be used by Anna, a Marketing staff member.
- You may need to install the Exchange Online PowerShell module if it’s not already installed.
- You need to be assigned permissions before you can perform this procedure or procedures. To see what permissions you need, see the “Recipients” entry in the Feature permissions in Exchange Online topic.
Let’s get started!
Load the Exchange Online PowerShell module
After you’ve installed the module, open a PowerShell window and load the module by running the following command:
Connect and authenticate to Exchange Online
Connect-ExchangeOnline -UserPrincipalName firstname.lastname@example.org
email@example.com is your admin account which has permissions to create mailboxes
Create the mailbox
New-Mailbox -Shared -Name "Marketing (Contoso)" -PrimarySmtpAddress firstname.lastname@example.org
Configure the mailbox to retain a copy of emails sent
By default, messages sent from a shared mailbox aren’t saved to the Sent Items folder of the shared mailbox. With the command below, the sent mail will be saved to both the Sent Items folder of shared mailbox and to the user mailbox’ sent items.
set-mailbox email@example.com -MessageCopyForSentAsEnabled $True
set-mailbox firstname.lastname@example.org -MessageCopyForSendOnBehalfEnabled $True
Grant Full Access and Send As permissions to Anna over the mailbox
Add-MailboxPermission -Identity "email@example.com" -User "firstname.lastname@example.org" -AccessRights FullAccess
Add-RecipientPermission -Identity "email@example.com" -Trustee "firstname.lastname@example.org" -AccessRights SendAs
Disconnect from Exchange online
Be sure to disconnect the session when you’re finished.
Et voilà ! You’re done.
You can also wrap all the steps above in a single script file as below:
Connect-ExchangeOnline -UserPrincipalName $AdminUser
New-Mailbox -Shared -Name $DisplayName -PrimarySmtpAddress $EmailAddress
set-mailbox $EmailAddress -MessageCopyForSentAsEnabled $True
set-mailbox $EmailAddress -MessageCopyForSendOnBehalfEnabled $True
Add-MailboxPermission -Identity $EmailAddress -User $DelegatedUser -AccessRights FullAccess
Add-RecipientPermission -Identity $EmailAddress -Trustee $DelegatedUser -AccessRights SendAs
In the script above, replace
$DelegatedUser with their actual values.
Thank you for reading this article all the way to the end! I hope you found the information and insights shared here to be valuable and interesting. Get in touch with me on LinkedIn
I appreciate your support and look forward to sharing more content with you in the future. Until next time!