How to Use New-RemoteMailbox in Powershell
If you manage mailboxes in a hybrid Exchange environment, the New-RemoteMailbox cmdlet is an essential tool.
Using New-RemoteMailbox simplifies the process of setting up a hybrid mail environment and enables mail routing between the on-premises Exchange server and Exchange Online.
Whether you're working with a single user or managing a large migration, understanding how to configure this cmdlet correctly can save you time—let’s get started!
What is New-RemoteMailbox in PowerShell?
The New-RemoteMailbox cmdlet is used in on-premises Exchange environments to create a mail user in Active Directory that is linked to a mailbox in a cloud-based service like Exchange Online.
This cmdlet is essential in hybrid deployments, where directory synchronization ensures the on-premises mail user syncs to the cloud, triggering the creation of the corresponding mailbox.
Similarly, the Enable-RemoteMailbox cmdlet is used to enable a remote mailbox for a user in an on-premises Exchange environment, and it can be used in conjunction with New-RemoteMailbox to create and configure a remote mailbox for hybrid Exchange setups.
Here’s the syntax of New-RemoteMailbox in PowerShell:
New-RemoteMailbox [-Name] <String> [-Password <SecureString>] [-Room] [-UserPrincipalName <String>] [-ACLableSyncedObjectEnabled] [-Alias <String>] [-Archive] [-Confirm] [-DisplayName <String>] [-DomainController <Fqdn>] [-FirstName <String>] [-ImmutableId <String>] [-Initials <String>] [-LastName <String>] [-ModeratedBy <MultiValuedProperty>] [-ModerationEnabled <Boolean>] [-OnPremisesOrganizationalUnit <OrganizationalUnitIdParameter>] [-PrimarySmtpAddress <SmtpAddress>] [-RemotePowerShellEnabled <Boolean>] [-RemoteRoutingAddress <ProxyAddress>] [-ResetPasswordOnNextLogon <Boolean>] [-SamAccountName <String>] [-SendModerationNotifications <TransportModerationNotificationFlags>] [-WhatIf] [<CommonParameters>] |
What Can You Use New-Remote Mailbox For?
Let’s take a look at three things you can do with this PowerShell command:
- Create a Mail User and Associated Cloud Mailbox: You can use the cmdlet to create a new mail user in your on-premises Active Directory and it will automatically create an associated mailbox in a cloud-based service like Office 365, assuming directory synchronization is set up.
- Create a Mailbox with Archive: You can create a new mail user in the on-premises Active Directory, while also creating a cloud-based mailbox for them, and optionally add an archive mailbox in the cloud. This is useful for users who need email archiving but don’t yet have a mailbox set up.
- Configure Mailbox in Specific Organizational Unit (OU): You can specify the Organizational Unit (OU) in which the mail user will be placed on the on-premises directory. This is useful for administrative purposes, like organizing users by department or role.
Prerequisites to Run New-RemoteMailbox in PowerShell
Before running New-RemoteMailbox, admins and users must meet these prerequisites:
- Exchange Server or Office 365: The New-RemoteMailbox cmdlet requires access to either an on-premises Exchange server or Exchange Online in Office 365. For Exchange Online, you’ll need to use PowerShell connected to your Office 365 environment.
- Mailbox Access: You need to have the necessary permissions to access and search mailboxes. This typically means being an Exchange administrator or having a role such as "Compliance Search" that grants permission to perform searches on user mailboxes.
- Exchange Management Role: You need to be assigned roles like "Discovery Management" or "Mailbox Search." These roles provide the necessary permissions to run searches and access specific mailbox data across the organization.
How to Use New-RemoteMailbox in 5 Steps
Using New-RemoteMailbox is quite simple, so let’s do it in just five steps!
Step 1: Connect to Exchange Online
To use the New-RemoteMailbox cmdlet, you need to first connect to your Exchange Online environment.
Open PowerShell on your computer and enter the following command:
Connect-ExchangeOnline -UserPrincipalName youradmin@meetingroom365.com |
This command establishes a remote session to Exchange Online using your credentials.
Step 2: Run the Cmdlet Create a Remote Mailbox
To create a new remote mailbox for a user, we’ll use the New-RemoteMailbox cmdlet. The basic syntax for creating a remote mailbox is:
New-RemoteMailbox -Name "James Smith" -UserPrincipalName "james.smith@meetingroom365.com" -Alias "james.smith" -RemoteRoutingAddress "james.smith@meetingroom365.mail.onmicrosoft.com" |
This command creates a remote mailbox for James Smith with the appropriate routing address.
As you can see here, you need to complete all the parameters with the information you want to add to the mailbox. Here’s a quick explanation:
- Name: Specifies the display name of the user.
- UserPrincipalName: The user's email address in Exchange Online.
- Alias: A shorter email alias for the user.
- RemoteRoutingAddress: The email address that routes mail to the user's on-premises Exchange server.
Step 3: Set Additional Attributes (Optional)
You can also set additional attributes such as OrganizationalUnit, Department, and Title while creating the remote mailbox.
For the user Simon John, the command might look like this:
New-RemoteMailbox -Name "Simon John" -UserPrincipalName "simon.john@meetingroom365.com" -Alias "simon.john" -RemoteRoutingAddress "simon.john@meetingroom365.mail.onmicrosoft.com" -Department "Sales" -Title "Manager" |
This command creates a remote mailbox for Simon and assigns additional information about his department and title.
Step 4: Verify the Creation of the Remote Mailbox
Once you've created the remote mailbox, you can verify its creation by running Get-RemoteMailbox like this:
Get-RemoteMailbox -Identity "James Smith" |
This will display the details of James Smith's remote mailbox, ensuring the mailbox has been created correctly.
Step 5: Disconnect from the Session
Once you've finished creating the remote mailboxes, it’s important to disconnect from the Exchange Online session to free up resources.
emove-PSSession -Session $session |
And that’s how you can easily use New-RemoteMailbox.
Wrapping Up: Mastering the New-RemoteMailbox Cmdlet
By using New-RemoteMailbox, you can ensure that your on-premises and cloud-based mail systems work seamlessly together. Understanding how to apply it properly will help you efficiently manage remote mailboxes and simplify your migration process.
Here’s a quick recap—good luck with your remote mailbox setup!
- The New-RemoteMailbox cmdlet helps create and configure remote mailboxes for users migrating to Office 365.
- The commands allow mail flow between on-premises Exchange and Exchange Online, ensuring a smooth hybrid setup.
- If the cmdlet isn't working, check for permission issues, ensure proper configuration of your hybrid environment and verify the user exists in Active Directory.