Labs: Crear gran numero mailbox para test

Create Large Numbers of Test Mailboxes.

Descargar script

This script will allow you to create test mailboxes to use in your proof of concept, lab or test environment.

If you’re setting up a lab environment to test with, then you will probably want to crate test users within the environment.

You can use the following commands, either at the Exchange Management Shell or as a script to create these users:


$FirstNames = Get-Content .\FirstName.txt

$LastNames = Get-Content .\LastName.txt

$UsersToCreate = 1000

$Password = ConvertTo-SecureString “pass@word1” -AsPlainText -Force

$OU = “lisajanedesigns.local/People”

$Departments = “Finance”,”IT”,”Marketing”,”Engineering”,”Sales”,”Human Resources”

$UPNSuffix = “lisajanedesigns.local”

foreach ($Department in $Departments)


New-DistributionGroup -Name $Department -OrganizationalUnit $OU


for ($i=0; $i -lt $UsersToCreate; $i++)


$FirstName = $FirstNames[(Get-Random -Minimum 0 -Maximum ($FirstNames.Count-1))]

$LastName = $LastNames[(Get-Random -Minimum 0 -Maximum ($LastNames.Count-1))]

$Username = “$($Firstname).$($LastName)”

$DisplayName = “$($Firstname) $($LastName)”

$Department = $Departments[(Get-Random -Minimum 0 -Maximum ($Departments.Count-1))]

New-Mailbox -Name $DisplayName -SamAccountName $Username -UserPrincipalName”$($Username)@$($UPNSuffix)” -Alias $Username -OrganizationalUnit $OU -Password$Password -FirstName $FirstName -LastName $LastName

Set-User -Identity $Username -Department $Department

Add-DistributionGroupMember -Identity $Department -Member $Username



 In the above example, alter the following values to match your environment:

  • Change the number of $UsersToCreate to match the number of test users you need.
  • Change the $Password value to a suitable password to use with each test user.
  • Change the $OU value to an Organizational Unit within your lab’s Active Directory.
  • Change the list of $Departments to a suitable list of test departments you want the script to create distribution groups for and randomly assign test users to.
  • Finally change the $UPNSuffix value to a User Principal Name suffix suitable for your environment.

The script will then create a number of test distribution groups, and then create new users with mailboxes with randomly assigned names. Each user will have a department randomly assigned and be added to a distribution group.

If you’re looking for sample names to use with the script, you can download files that work with the above Powershell script from here. Extract those files to the same directory that you plan to execute the script from.


Be the first to comment

Leave a Reply