MS-Exchange & Office 365, Create Mailboxes and Dummy Emails for Testing

mailbox-lockI was recently testing a new email backup product that pushed me to a new test requirement. I needed to create a huge number of mailboxes, and then send dummy emails to fill the newly created mailboxes to simulate a production email system.

Luckily, I have been working with Microsoft Exchange for the last 16 years; but in recent years my path diverted from designing, deploying, configuring, and managing MS Exchange environments.

During my weekend, I went back to MS Exchange Admin mode to test the new backup product for the customer requirements we are going to review below.

The customer had the following requirements:

  • Multi-Databases Server
  • 6000 mailboxes
  • 10 Mb mailbox size each

Of course, creating 6000 mailboxes manually is not an easy or quick task. If you are prepared to sit for the rest of your life manually creating 6000 mailboxes, then you should stop reading now and head on to the MS Exchange ECP to commence your new life task.

Or, you could follow us to the PowerShell script below to help you accomplish the task quickly.

Create Multi-Databases:

New-MailboxDatabase -Name “Database01” -EdbFilePath S:\ExchangeDatabases\Database01\database01.edb

Create 6000 Mailboxes

Create a .ps1 file and add the following.

$Password=Read-Host “Enter Password” –AsSecureString
$Number = 1
$Domain = “veeamsalab.org”
$Database = “Database01”
$OU = “DBTest_Users”
while ($Number -lt 6000){
New-Mailbox -UserPrincipalName “User$Number@$domain” –
OrganizationalUnit $OU -Alias User$Number -Name “User$Number” –
firstname “User$Number” -database $database -Password $PAssword
$Number = $Number + 1
}
write-host “All Test Mailboxes created”

Sending Dummy Emails for the 6000 Mailboxes

Create a .ps1 file and add the following.

$Number = 1
$from = “hyaman@lab.org”
$Domain = “lab.org”
while ($Number -lt 6000){
Send-MailMessage -from $from -To User$number@$domain -Subject
“Testing” -Body “This is a testing Emails – Random emails” -Attachments
“s:\test10Mb.txt” -SmtpServer localhost
$Number = $Number + 1
}
write-host “All Test Mailboxes created”

What about Office 365

Imagine if you wanted to create multiple users (bulk) on MS Office 365? Well, the steps are similar to what we already went through; except, we adjust and point our PowerShell to create the users remotely.

To do this remotely, we need the packages below to be installed on the station from where you are going to run the script:

UserCredential = Get-Credential
Connect-MsolService -Credential $UserCredential
$Number = 1
$domain = “Veeamsalab.onmicrosoft.com”
while ($Number -lt 6000){
New-MsolUser -DisplayName “tUser$Number” -UserPrincipalName           “tUser$Number@$domain” -firstname “tUser$Number” -LastName “User$Number”
$Number = $Number + 1
}
write-host “All Test Mailboxes created”

Conclusion

Following the above steps made my MS Exchange testing task so much simpler; in fact, it would not be possible without those scripts. Also, let me confirm that backing up on-premises MS Exchange servers with a huge number of mailboxes can be handled by the tested backup product.

It is a win-win situation for testing, and I  experienced a little of MS Exchange PowerShell from the past. Whether you are looking for someone experienced to test the backup of a vast number of mailboxes; or, is learning how to create bulk MS Exchange mailboxes, I hope me sharing this blog helped you with your query.

One thought on “MS-Exchange & Office 365, Create Mailboxes and Dummy Emails for Testing

Leave a Reply