Bulk creation of mailboxes (and the accompanying user accounts) in Exchange Server 2003/2000 involved some elaborate scripting effort. This task can now be done fairly effortlessly, thanks to the Exchange Management Shell (EMS). The Shell can very easily import/use CSV files saved from a spreadsheet or text editor and create the mailbox-enabled users. Here’s how.

Create a spreadsheet

Create a spreadsheet (you can also use a standard text editor such as Notepad to create a CSV file) with the following columns. You can add more fields if you wish:

Alias,Name,UPN

Add data for new accounts in following lines/rows. Here’s what it’ll look like:

How the Shell interprets the command

Here’s how the shell interprets the above command:

Import-csv CreateRecipeints.csvgets data from the CSV file.

If you’re providing the complete path with spaces, you must enclose it in quotes. For example: “c:\My Scripts\CreateRecipients.csv”.- If you’re not running the command from the same directory (folder) where the CSV file is located, you will need to provide the complete path to the file.

- The | pipes the data from the CSV to the next command.

- foreach parses through each line in your CSV file, using the first row as a header. All the column headings/names get treated as field names.

- The New-Mailbox command, as you may already know by now, creates a new mailbox-enabled user.

- For each variable, you either enter a value at the command line(for instance, we’re using the value “Mailbox Database” for the Store), or you can pick up the value from your CSV file provided you have a column for it with a heading. For instance, for the -alias field, we use $_.alias – which tells the script to look for the column called alias in your CSV file and pick up the value from the current row or line.

If you’re running the command on the same server where you want to create the mailboxes, you can simply use the Store name, e.g. “Mailbox Store”. To create mailboxes on another server’s Store(s), you can use either ServerName\Store, or ServerName\StorageGroup\Store, or even the GUID of the Store. How do you get those??? Use the Get-MailboxDatabase cmdlet.

- The -OrganizationalUnit field stands for (Active Directory) OU (or Container) you want to create the accounts in. If all the accounts you create from the CSV file will reside in the same container or OU, you can provide this at the command-line, as we did in the example above. Alternatively, you can include the OU/Container name in your spreadsheet/CSV file in a field – let’s say OU – and modify your command to say: -org $_.OUNote: Luckily you do not need to provide the distinguishedName of the OU or Container – simply the name of the OU or Container works.

- The -password field picks up the password from the variable called $password that we created earlier.

The New-Mailbox cmdlet allows you to enter a lot of attributes for each mailbox-enabled user. These are documented in the New-Mailbox cmdlet reference docs (Exchange 2007 | Exchange 2010), and also in the Exchange 2007/2010 online help. For each attribute you want to populate, add it to your spreadsheet/CSV file.

Updates

July 9, 2007: To create new mailboxes with settings based on an existing mailbox, use the TemplateInstance parameter, as shown in the following commands:

What other AD attibutes can be added here? I’d like to add a custom attribute (staff ID number). Is there a list of attributes that can can be added to the csv file and imported with each user? Thanks so much.

The last paragraph in the post has a link to Microsoft’s online documentation for new-mailbox command, which lists all the parameters that you can add. The list includes custom attributes as well as plenty of others.

Thanks Bharat, this blog gives too much info regarding the bulk Ids, and now Im using the script to run (ps1), I have query here, in the Company field I would like to put the employee number when I start using the script, due to this, most of the time these IDs will show the “INA” and users never update the directory and when we do a random check on the servers these ids will be inactive and we will delete those Inactive IDs.. any solution for this?

Hopefully this is the last question, They said that we would have to run 2 different shells win and the exchange shell is there a way to run both without having to do 2 different programs, i guess like a all in one program that will do both

Hello Bharat
I have already created the bulk exchange 2007 mailboxes. I am now trying to create the AD Home folders for these mailboxes/users. Would you have any idea how I can get this done easily? Thanks for your helpful post.

It is the best article I can find for this, a little extensive explanation is very helpful for the trick. Most of articles are written for authors’ self-reading and it is hard to understand for others.