Link to home
Start Free TrialLog in
Avatar of Olevo
OlevoFlag for Australia

asked on

How do you create mailboxes for an existing users in Exchange 2013?

How do you create mailboxes for an existing users in Exchange 2013? From what I can see, with exchange admin center (EAC) you can’t select more than one existing user in Active Directory. Well, I don't really want to do it one by one for the 130 users. In Exchange 2007 it was very easy task to do inside the exchange management console.
I need a bit of help with the Exchange 2013 PowerShell command to create (enable) mailboxes for the existing users in OU. Keep in mind that some users in OU already have mailboxes enabled and some don’t. Mailboxes for all users in OU will be created on the same Exchange database.
Thanks in advance
Avatar of Emmanuel Adebayo
Emmanuel Adebayo
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,

You can use the Enable-Mailbox See the usage below

Enable-Mailbox -Identity Domain\username -Database <Exchange>

This will create a mailbox for the existing username. The mailbox is created in Exchange.
Regards
ASKER CERTIFIED SOLUTION
Avatar of Simon Butler (Sembee)
Simon Butler (Sembee)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of schmiegu
schmiegu

Try this:
Get-ADUser -Searchbase 'OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM' -Filter "*" -Properties * | Where {!($_.HomeMDB)} | Enable-Mailbox -Database "ABC"

I search an OU (and Sub-OUs) for all users, then apply a filter to the users, that don't have a mailbox database and then I enable the mailbox. Instead of enabling the mailbox you may want to display the results: Ommit the last pipe or use e.g. "ft DistinguishedName"

BTW: I don't know a cmdlet "Get-User"
Avatar of Olevo

ASKER

Thanks schmiegu, your solution is exactly what I want, however...
Before I'm going to enable mailboxes for the existing AD users in OU I would like to know which user doesn't have mailbox in  Exchange 2013 Server.
Running following powershell command in Exchange console:
Get-ADUser -Searchbase 'OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM' -Filter "*" -Properties * | Where {!($_.HomeMDB)}
... shows all users in OU (with and without mailbox in Exchange server) and all of them have 'HomeMDB' field empty?!  Perhaps we need to filter by different field...
This command shows only the users, that don't have a mailbox. They don't even have the property HomeMDB - they get this (and a lot of others) with enable-mailbox. To see the users with mailboxes, the where clause would read: Where {$_.homeMDB}.
To see the different properties you can use:
Get-ADUser MailEnabledUser -Properties * | gm 

Open in new window

or
Get-ADUser NotMailEnabledUser -Properties * | gm

Open in new window

You can filter on any of the properties, a not mail enabled user doesn't have. HomeMDB is one of them - and I'm used to use this property for filtering.
Avatar of Olevo

ASKER

Sorry schmiegu but your proposed powershell command just don’t work for me ;-( Perhaps, something else needs to be added or removed from the command?!

Get-ADUser -SearchBase 'OU=Staff,DC=FABRIKAM,DC=COM' -Filter "*" -Properties * | where {!($_.homeMDB)} | Enable-Mailbox -Database “Staff”
~~~Error~~~
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
    + CategoryInfo          : InvalidArgument: (CN=Kate Smith,OU...ff,DC=COM:PSObject) [Enable-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Enable-Mailbox
    + PSComputerName        : ex2013srv.fabrikam.com
~~~

Anyway, looks like Simon Butler (Sembee) was on a right track here. Here is the PowerShell command I have used and all works fine for me.

Get-User -OrganizationalUnit "Staff" -RecipientTypeDetails User | Enable-Mailbox -Database Staff

FYI: Here is some info from :
Microsoft Exchange Server 2013 PowerShell Cookbook (Second Edition) by Jonas Andersson and Mike Pfeiffer
Chapter 3: Managing Recipients (Page 88-89)
===
The only requirement when running the Enable-Mailbox cmdlet is that you provide the identity of the Active Directory user that should be mailbox-enabled. In the previous example, we've specified the database in which the mailbox should be created, but this is optional. The Enable-Mailbox cmdlet supports a number of other parameters that you can use to control the initial settings for the mailbox.

You can use a simple one-liner to create mailboxes in bulk for existing Active Directory users:

Get-User -RecipientTypeDetails User |Enable-Mailbox -Database DAGDB1

Notice that we've run the Get-User cmdlet specifying User as the value for the -RecipientTypeDetails parameter. This will retrieve only the accounts in Active Directory that have not been mailbox-enabled. We then pipe those objects down to the Enable-Mailbox cmdlet and mailboxes are created for each of those users in one simple operation.
===
Now I've found the get-user cmdlet (the exchange management snap-in is needed, which I have not installed on my workstation).
It seems, the -Identity param of enable mailbox doesn't accept distinguished names, so maybe an additional pipe (| select  UserPrincipalName) would solve the problem (according to the enable-mailbox help examples Identity shoul accept UPNs and Domain\user).

But Get-User is the way to go.