<link href="https://fonts.googleapis.com/css?family=Roboto:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic&amp;display=swap" rel="stylesheet"/>
2 minutes reading time (478 words)

Creating a User Mailbox in an Exchange Hybrid using PowerShell

This guide will show you how to use PowerShell to create a user mailbox in an Exchange Hybrid.

Create a User Mailbox using PowerShell

In an Exchange Hybrid with Office 365 mailboxes should be created and managed using the on-premises Exchange server

Creating mailboxes in this way means that the mailbox is created in Exchange on-premises, the user is synced to Office 365 and the AD user object has the right Exchange attributes for a Hybrid environment

On Exchange server - open Exchange Management Shell (run as Administrator)

Enter the password for the new mailbox

$password = Read-Host "Enter in the password" -AsSecureString

Create the mailbox

New-Remotemailbox -Alias PhilipFry -Name "Philip Fry" -FirstName "Philip" -LastName "Fry" `
-OnPremisesOrganizationalUnit "OU=Users,OU=TechLabs,DC=techlabs,DC=me,DC=uk" `
-SamAccountName Philip.Fry -UserPrincipalName philip.fry@techlabs.cloud -Password $password

New-Remotemailbox -Alias PhilipFry -Name "Philip Fry" -FirstName "Philip" -LastName "Fry" `
-OnPremisesOrganizationalUnit "OU=Users,OU=TechLabs,DC=techlabs,DC=me,DC=uk" `
-SamAccountName Philip.Fry -UserPrincipalName 'EMAIL_ADDRESS' -Password $password  

New-RemoteMailbox Options

-OnPremisesOrganizationalUnit
Specify the Active Directory OU for the user account

-Archive
creates an archive mailbox

-PrimarySmtpAddress
Sets the email address. You only need to use this option if you want an email address that is different from your address policy

-ResetPasswordOnNextLogon
User must change password at the next logon, $true or $false

Directory Sync

To manually run a directory sync

Logon to your Azure AD connect server and run this PowerShell

Start-ADSyncSyncCycle -PolicyType Delta

Assign a License in Office 365

Connect to Azure AD

Connect-MsolService

List all unlicensed users

Get-MsolUser -All -UnlicensedUsersOnly

Get a list of licenses available for your subscriptions. You'll need the AccountSkuId to assign a license

Get-MsolAccountSku

Set the usage location to GB for United Kingdom

  • The location is used to set the global location (or country) of Office 365 services for the mailbox
  • The mailbox will be created in this Office 365 region, some services may not be available in certain countries so it's important to set the location correctly
  • The location is also used to set the date, time and language format for users

Set-MsolUser -UserPrincipalName "philip.fry@techlabs.cloud" -UsageLocation GB

Assign a license to a user

Set-MsolUserLicense -UserPrincipalName "philip.fry@techlabs.cloud" -AddLicenses "techlabsme:ENTERPRISEPACK"

List a user's licenses

Get-MsolUser -UserPrincipalName "philip.fry@techlabs.cloud" | Format-List DisplayName,Licenses

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Friday, 31 October 2025
You can help support this website by buying me a coffee!
Buy Me A Coffee