Software

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 'contoso.com/Users/John 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,
CN=335A1087-5131-4D45-BE3E-3C6C7F76F5EC,CN=Microsoft
Exchange,CN=Services,CN=Configuration,
DC=contoso,DC=com'

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.

4 comments
jtimonina
jtimonina

Enter "Enable-Mailbox -Identity server/Users/User Name" and replace the "server" and "User Name" portions with the name of your server and user name you want the mailbox created for. Thats all i know. Julia Timonina

qlas
qlas

The GUID can be replaced with "" making this much simpler. Still, it I miss the ADUC integration.

tshinder
tshinder

The Exchange 2007 team must have been on crack when they decided that monad should be the way to manage the Exchange box. Even in the MS demos, they copy and paste these complex commands since they can't remember them. How about creating a functional and useable User Interface?