How to create users and shared mailboxes in a Hybrid Exchange environment. If you are running a hybrid environment, with Active Directory and Exchange on-premises together with Office 365 and Exchange Online, you need to keep your Exchange Server(s) to correctly manage your mailboxes.
The Exchange Management Console, Exchange Administration Center (EAC), and Exchange Management Shell are the only supported tools to manage Exchange recipients and objects.

Connect to your on-premises Exchange PowerShell first.
New-RemoteMailbox -Alias auser -Name "Alex User" -FirstName Alex -LastName User -OnPremisesOrganizationalUnit "OU=MyOrg,DC=domain,DC=com" -SamAccountName auser -UserPrincipalName alex.user@domain.com -ResetPasswordOnNextLogon:$false
I normally use a CSV file with Alias, DisplayName, FirstName, LastName, UPN columns.
Your script should also add users into the required groups for licensing, assuming you are using group-based licensing — otherwise the mailbox will be deleted in 30 days.
New-Remotemailbox -Shared -Alias test_shared -Name "Test Shared" -FirstName Test -LastName Shared -OnPremisesOrganizationalUnit "OU=MyOrg,DC=domain,DC=com" -SamAccountName test_shared -UserPrincipalName test.shared@domain.com
When you create a shared mailbox like this, there is no password and the account will be disabled, as it should be. Shared mailboxes created correctly do not need any license since the account is disabled.