Exchange 2007: Create a new mailbox from the command line

Scott Lowe provides a step-by-step account of how to create a new mailbox in Exchange 2007.

With its PowerShell-based command line, Exchange 2007 opens up huge possibilities when it comes to automating account and mailbox creation. In Exchange 2007, the mailbox creation process has been de-linked from account creation. In other words, when you create an Active Directory account, Active Directory Users and Computers (ADUC) no longer prompts you asking if you want to create an Exchange mailbox to go along with the new user.

Whether or not this was a mistake on Microsoft's part is moot at this point. In any case, account and mailbox creation becomes a two-step process. So, the steps you see here assume that you have already created a user account in Active Directory—either manually or via a script.

I should point out here that, while Exchange management has been removed from ADUC, you can create a new AD account from within the Exchange Management Console (EMC) by going through the mailbox creation wizard. I will not be covering the creation of an AD account from that tool in this tip, however, as the EMC is not as full-featured as ADUC when it comes to managing user account attributes.

When you create a mailbox from the GUI, you need to specify the mailbox type (User, Room, Equipment, or Linked), tell the EMC which Exchange server you want to host the new mailbox, and choose a storage group and mailbox database from that server. You need to specify similar information if you opt to use the command line.

As a test, I created a couple of user accounts in AD. The first one, Jack Doe, is a fake account that I'll use to determine the parameter values that I need for scripting. The new GUI shows you the output from all of the commands you perform to make it easier to script. You'll see how important this is in a second.

Figure A shows the output from the Exchange Management Console from my task of creating a mailbox on the server named E2007-3 for the user named Jack Doe.

Figure A

The output from the Exchange Management Console.

Note the complexity of some of the objects you need to address in your mailbox creation script.

Now, you probably have not memorized the GUID for every object in your Exchange organization, but you need to use it in some commands, as you can see in Figure A. Using this output as a template, I'll create a mailbox for the user named John Doe.

Enable-Mailbox -Identity ' Doe' 
-Alias 'john.doe' -Database 'CN=Mailbox Database,
CN=First Storage Group,CN=InformationStore,
CN=E2007-3,CN=Servers,CN=Exchange Administrative Group
(FYDIBOHF23SPDLT),CN=Administrative Groups,

When complete, the shell responds back with a little information about the new mailbox, as you can see in Figure B.

Figure B

Here is some information about the new mailbox.

The mailbox was created successfully.

Editor's Picks

Free Newsletters, In your Inbox