Thursday, August 19, 2010

Bulk creating of users and mailboxes in Exchange 2007

The first part of this document will cover only the basics of creating users in AD and their mailboxes in Exchange server 2007.
The second part of this document specifically deals with bulk creating of users and creating their mailboxes in Exchange Server 2007.
The third part will discuss on enabling users with their mailboxes in Exchange server 2007.

Creating one user in AD and creating its mailbox in Exchange 2007 is very easy task. One can do this through Exchange management Console (EMC) or Exchange management shell (EMS) with no deep knowledge on the product.


Below are the step by step guidelines on creating a user and a mailbox through EMC and EMS.




























In the EMC, you get the option to create new mailbox when you select the “mailbox” under “recipient configuration”.
Unlike in Exchange 2000/03 server here, in Exchange Server 2007 you get the options to create multiple types of mailboxes.
You can always have mailboxes for users and that’s where you get the option to create “User mailbox”.

You can have mailboxes for resources like conference rooms or a projector or a meeting room or any other resource in your company and for that you get the option to create “Room mailbox” or “Equipment Mailbox”.


You can also create linked mailbox for users who does not have a user account in the same AD forest where the mailbox is.


The next step is where you are asked to create a new user for a new mailbox or an existing user who is yet to have his mailbox.






























We can always select the existing user if the user already exist in the AD and we need to enable his mailbox in the Exchange server 2007.
One you choose to create a new user, you should see the next console something like the one below.






























Then, you will be prompted for the mailbox information such as the Mailbox Server name and the Mailbox database, etc.

Then comes the summary page and then the finishing page where you can also see the command to create a new mailbox with a new user account which you can use with Exchange Management Shell.






























This was all about creating a new mailbox for new user or an existing user account through Exchange Management Console.
Now let’s see creating mailboxes through Exchange Management Shell.

This is how it goes.
To create a new mailbox for a new user account, the command is: New-Mailbox with some switches as mentioned below:


[MSH] C:\Documents and Settings\Administrator>New-Mailbox -Name Mohini -FirstName Mohini -LastName Giri -Alias Mohini -UserPrincipalName mohini@universe.net -OrganizationalUnit universe.net/test -Database "mailbox database"


cmdlet New-Mailbox at command pipeline position 1


Supply values for the following parameters:


Password: *******


Name    Alias    Server    ProhibitSendQuota
----        -----      ------      ---------------
Mohini   Mohini dcexsrvr01 unlimited


The lines above in yellow and the screen shot below are explained here:


As said earlier, for new user and new mailbox the command is New-Mailbox. Further we need to all the mandatory information about the new user and his mailbox information.


Mandatory user information is “Alias, Name, Organizational Unit, etc”. “First name, Last name” are really not required but we just gave those in this example.


Mandatory mailbox information would be like “database name where mailbox will reside, server name, etc”





















In case, you need to create a new mailbox for existing users, your command would be as below:


[MSH] C:\Documents and Settings\Administrator>Enable-Mailbox -Identity: "universe.net/aa/pravin Giri" -Alias pravin -Database "mailbox database"


Name         Alias    Server       ProhibitSendQuota
---- -----      ------    -----------   ------------------------
Pravin Giri  pravin  dcexsrvr01         unlimited      






















Now the real tough task is when we need to create multiple user accounts in AD and their mailbox in Exchange Mailbox Server.
Or when we have multiple user accounts in AD and we need to enable them with the mailboxes on the exchange server at one shot.


How do we do it?
Can we do it through Exchange Management Console?
Can we just select the user accounts in AD and perform the Exchange task?

These are few questions which you will come across and here’s the answer for those.
Well, to be very frank, there’s really no option to go to the exchange task in AD and user’s properties.
There’s also no way we can do it through Exchange Management console.
We can achieve these goals through some scripting knowledge and with the help of Exchange Management Shell.

Let us first have a look at the script on creating bulk mailboxes for users in AD.



























In this example, I have an OU with the name CanadaUsers and few accounts within it who are yet to have their mailboxes.

Now, let’s see how do we do this.

First, we need to find users in AD without mailboxes.

To do so, we give the command,


[MSH] C:\Documents and Settings\Administrator>Get-User -OrganizationalUnit canadausers
where-object{$_.recipienttype -eq "user"}

Name      RecipientType
-------       -----------------


david thomas     User
Mike Williams      User
jonathan lile       User
sharon smith      User
richard jose        User

The same command is available in the screenshot below as well.






















Now since the output is available to us, we need to enable users with their mailboxes.
So we further, put the output in the pipe and we enable the mailboxes.

This is done as given below.


[MSH] C:\Documents and Settings\Administrator>Get-User -OrganizationalUnit canadausers
where-object{$_.recipienttype -eq "user"}
Enable-Mailbox -Database "mailbox database"


Name            Alias         Server            ProhibitSendQuota
-------            -----           ------             -----------------------


david thomas david     dcexsrvr01      unlimited
Mike Williams  mike      dcexsrvr01      unlimited
jonathan lile   jonathan dcexsrvr01    unlimited
sharon smith  sharon    dcexsrvr01    unlimited
richard jose    richard    dcexsrvr01    unlimited























Sounds a little easy hmm…. But this time we already had users in the AD. We just had to filter them and then enable their mailboxes.

Now, we’ll create some users in AD and their mailboxes as well.
Let’s see how do we do this.
First thing that I would like to do is , ensure that I follow the password policy of my company


So I prefix the password for all the users who will be created through EMS.


Here’s how we do it.


[MSH] C:\Documents and Settings\Administrator>$password=read-host "Please Enter the Password" -assecurestring


Please Enter te Password: *******

This will save the password format in the EMS unless it is changed or we close the EMS.

The second command we give is to create the users in the .csv format and import it to create their mailboxes.
For the convenience, we have already created a users.csv file and this is how it looks.


















In the EMS, this is what we give and what the output looks like. In our case, Sachin was already a user account in the AD and no two accounts with the same name can be created so it gave us an error. For the rest of the user, it just triggered and here’s the output.





















Of course, there are many different ways we can create mailboxes and user accounts in the AD and this is one way how I do it.


I hope after going through this document you should be able to create and test your labs with regards to bulk creation of users in AD and mailboxes in Exchange server 2007.

No comments:

Post a Comment