Create new mailboxes on Exchange 2013 using EMS

Here is a quick way to create one or many mailboxes (and the respective user account on AD) on Exchange 2013 using the Exchange Management Shell

The below script will create a user “Test user” with username “testuser” in the OU “Domain/Users”

first provide a password:
[sourcecode language=”powershell”]
$password = Read-Host "Enter password" -AsSecureString
[/sourcecode]
then create the mailbox:
[sourcecode language=”powershell”]
New-Mailbox -UserPrincipalName [email protected] -Alias testuser -Database "Mailbox Database XXXXXXX" -Name testuser -OrganizationalUnit ‘domain/users’ -Password $password -FirstName test -LastName user -DisplayName "test user"
[/sourcecode]
If you want the user to change password at first logon then add the “-ResetPasswordOnNextLogon $Right” at the end of the script

The below script will use a csv file as a list to create multiple users based on the data on the list.

first create a csv file with titles “UPN,Alias,Database,Name,OU,First,Last,Display” and fill the details of the users and save it at c:users.csv

second provide a password (this will be common to all users, you can also add a “password” field at the list and add a random password to each user):
[sourcecode language=”powershell”]
$password = Read-Host "Enter password" -AsSecureString
[/sourcecode]
then create the mailboxes:
[sourcecode language=”powershell”]
Import-Csv C:users.csv | foreach { New-Mailbox -UserPrincipalName $_.UPN -Alias $_.Alias -Database $_.Database -Name $_.Name -OrganizationalUnit $_.OU -Password $password -FirstName $_.First -LastName $_.Last -DisplayName $_.Display -ResetPasswordOnNextLogon $Right }
[/sourcecode]

To create a Shared Mailbox the command is almost the same:
[sourcecode language=”powershell”]
New-Mailbox -Name "Display Name" -Shared
[/sourcecode]

To create Shared Mailboxes from a csv list run:
[sourcecode language=”powershell”]
Import-Csv C:tempshared.csv | foreach {New-Mailbox -Name $_.DisplayName -Shared}
[/sourcecode]

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.