Microsoft 365: Create a shared mailbox in Exchange online with Powershell
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 (marketing@contoso.org
) for the Marketing department. That mailbox will be used by Anna, a Marketing staff member.
Prerequisites:
- 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!
Procedure
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:
Import-Module ExchangeOnlineManagement
Connect and authenticate to Exchange Online
Connect-ExchangeOnline -UserPrincipalName admin@contoso.org
where admin@contoso.org
is your admin account which has permissions to create mailboxes
Create the mailbox
New-Mailbox -Shared -Name "Marketing (Contoso)" -PrimarySmtpAddress marketing@contoso.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 marketing@contoso.org -MessageCopyForSentAsEnabled $True
set-mailbox marketing@contoso.org -MessageCopyForSendOnBehalfEnabled $True
Grant access
Grant Full Access and Send As permissions to Anna over the mailbox
Add-MailboxPermission -Identity "marketing@contoso.org" -User "anna@contoso.org" -AccessRights FullAccess
Add-RecipientPermission -Identity "marketing@contoso.org" -Trustee "anna@contoso.org" -AccessRights SendAs
Disconnect from Exchange online
Be sure to disconnect the session when you’re finished.
Disconnect-ExchangeOnline
Et voilà ! You’re done.
You can also wrap all the steps above in a single script file as below:
$DisplayName="Marketing (Contoso)"
$EmailAddress="marketing@contoso.org"
$AdminUser="admin@contoso.org"
$DelegatedUser="anna@contoso.org"
Import-Module ExchangeOnlineManagement
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
Disconnect-ExchangeOnline
In the script above, replace $DisplayName
, $EmailAddress
, $AdminUser
and $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!