How to create and configure Linked Mailbox in Microsoft 365 Exchange online using PowerShell

How to create and configure Linked Mailbox in Microsoft 365 Exchange online using PowerShell

Linked mailboxes in Microsoft 365 Exchange Online are used in hybrid environments where both Active Directory and Exchange Online are used. They allow you to keep a user's mailbox on-premises while still being able to access it in the cloud. In this article, we will provide a step-by-step guide on how to create and configure linked mailboxes in Microsoft 365 Exchange Online using PowerShell.

 

Here's a step-by-step process on how to create a linked mailbox in Exchange Online:

 

  1. Connect to Exchange Online PowerShell.

To create and configure linked mailboxes, you must first connect to Exchange Online PowerShell. To do this, open PowerShell as an administrator, and run the following commands:

 

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

 

You will be prompted to enter your Microsoft 365 credentials. Once you are connected, you can start creating and configuring linked mailboxes.

 

  1. Run the following command to create a new remote mailbox in Exchange Online:

New-RemoteMailbox -Name <MailboxName> -OnPremisesOrganizationalUnit <OUPath> -Password (ConvertTo-SecureString <Password> -AsPlainText -Force) -LinkedDomainController <DCName> -LinkedMasterAccount <OnPremiseUserName>

 

Replace <MailboxName> with the name of the new mailbox, <OUPath> with the path to the organizational unit that the new mailbox will be created in, <Password> with a password for the new mailbox, <DCName> with the name of the domain controller for the on-premises environment, and <OnPremiseUserName> with the username of the mailbox in the on-premises environment that will be linked.

 

  1. Verify that the new remote mailbox has been created by running the following command:

Get-RemoteMailbox <MailboxName>

 

  1. Create a Mail-Enabled User

 

To link the remote mailbox to an on-premises user account, you must create a mail-enabled user in Active Directory. A mail-enabled user is a user account in Active Directory that has an email address associated with it.

To create a mail-enabled user, run the following command:

 

Enable-MailUser -Identityuser@zylker.com -ExternalEmailAddress user@zylker.mail.onmicrosoft.com -Alias user-LinkedCredential $UserCredential -LinkedDomainController "DC1.zylker.com"

 

Replace the values in the command with your own values. The -Identity parameter specifies the email address of the user account in Active Directory. The -ExternalEmailAddress parameter specifies the email address of the remote mailbox. The -Alias parameter specifies the alias for the user account. The -LinkedCredential parameter specifies the credentials for the on-premises user account. The -LinkedDomainController parameter specifies the domain controller to use for linking the mailbox.

 

  1. Run the following command to create a new linked mailbox in Exchange Online:

Enable-RemoteMailbox <OnPremiseUserName> -RemoteRoutingAddress <MailboxSMTPAddress>

 

Replace <OnPremiseUserName> with the username of the mailbox in the on-premises environment that will be linked, and <MailboxSMTPAddress> with the SMTP address of the mailbox in Exchange Online that will be linked to the on-premises mailbox.

 

  1. Verify that the new linked mailbox has been created by running the following command:
    Get-Mailbox <MailboxName>

 

Once the linked mailbox is created, you can manage it just like any other mailbox in Exchange Online. This includes setting permissions, creating rules, and setting up retention policies. By using linked mailboxes, organizations can easily move mailboxes between on-premises and online environments while maintaining the user's email history and other mailbox settings.

 

  1. Add Permissions and Manage Linked Mailboxes

 

  1. Assign Permissions: Assign the necessary permissions to manage linked mailboxes by running the following command:

Add-ADPermission -Identity<Linked Mailbox>-User<Admin Account>-AccessRights FullAccess -InheritanceType All

Replace the values in the command with the appropriate ones for your environment. This command will give full access rights to the admin account for the linked mailbox.


  1. Check Permissions: Verify that the permissions have been added by running the following command: 

Get-MailboxPermission <Linked Mailbox>|where {$_.user.tostring() -like'<Admin Account>'}

This command will display the permissions assigned to the admin account for the linked mailbox.


  1. Remove Permissions: If necessary, you can remove the permissions by running the following command: 

Remove-MailboxPermission-Identity<LinkedMailbox>-User<AdminAccount>-AccessRightsFullAccess-InheritanceTypeAll

Replace the values in the command with the appropriate ones for your environment. This command will remove full access rights from the admin account for the linked mailbox.


  1. Disable a Linked Mailbox: If you need to disable a linked mailbox, you can run the following command: 

Disable-RemoteMailbox -Identity <Linked Mailbox>

Replace the value in the command with the appropriate one for your environment. This command will disable the linked mailbox.


  1. Enable a Linked Mailbox: To re-enable a linked mailbox, you can run the following command: 

Enable-RemoteMailbox -Identity <UserAccount> -RemoteRoutingAddress <LinkedMailboxEmailAddress>

Replace the values in the command with the appropriate ones for your environment. This command will enable the linked mailbox.


  1. Remove a Linked Mailbox: To remove a linked mailbox, you can run the following command: 

Remove-RemoteMailbox-Identity<LinkedMailbox>

Replace the value in the command with the appropriate one for your environment. This command will remove the linked mailbox.

 Conclusion 

Linked mailboxes in Exchange Online allow you to link on-premises mailboxes with cloud-based mailboxes, providing a hybrid email solution for organizations. By following the steps outlined above, you can easily create, manage, and remove linked mailboxes, giving your users seamless access to their email regardless of their location.

 

 


    • Related Articles

    • How to remove a linked mailbox in Exchange online

      Once the linked mailbox is created, you can manage permissions and access to it. Here are the steps to do so: In the Exchange Admin Center, click on "Recipient" and then "Mailboxes". Search for the linked mailbox you want to manage and select it. ...
    • Microsoft 365 Exchange Online - Shared Mailboxes & PowerShell

      Introduction Overview of Shared Mailboxes 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 ...
    • Top 5 Mailboxes in Microsoft 365 Exchange Online – GUI method

      Microsoft 365 Exchange Online offers various types of mailboxes that serve different purposes, from archive mailboxes to inactive mailboxes. Each mailbox type has unique features and functionalities that can help improve email management in your ...
    • Microsoft 365 Exchange online - Shared Mailboxes & PowerShell

      Introduction Overview of Shared Mailboxes 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 ...
    • Configuring and Managing Microsoft 365 Exchange Online: A Technical overview

      Microsoft 365 Exchange Online is a cloud-based email messaging service designed to meet the communication needs of businesses of all sizes. Configuring and managing Exchange Online can be a complex task, but with the right knowledge and tools, it can ...