You sometimes need some (or even many) test user objects in Active Directory.
This script helps you create any number of test users in your Active Directory domain, which you can easily enable for on-premises or remote mailboxes afterward.
The Script
Enable mailboxes
Use your on-premises Exchange Management Shell to enable all test users with an on-premises mailbox.
$UserOU = 'OU=Test User,OU=IT,dc=varunagroup,dc=de' Get-User -OrganizationalUnit $UserOU | Enable-Mailbox -Confirm:$false
Use your on-premises Exchange Management Shell to enable all test users with a new remote mailbox in Exchange Online. Do not forget to change the tenant name of the remote routing address.
Get-User -OrganizationalUnit 'OU=Test User,OU=IT,dc=varunagroup,dc=de' | %{Enable-RemoteMailbox -Identity $_ -Confirm:$false -RemoteRoutingAddress "$($_.SamAccountName)@TENANT.mail.onmicrosoft.com"}
You find the most recent version of the script on GitHub.
Links
Enjoy.