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]
Pantelis Apostolidis is a Sr. Specialist, Azure at Microsoft and a former Microsoft Azure MVP. For the last 20 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.