Create a User and Mailbox in Powershell

Written by Allen White on. Posted in Exchange 2007, Exchange 2010

new-mailbox command

This command, when entered without parameters, will walk you through making an AD user with a mailbox, prompting you for the minimum required parameters.

While this might be enough to get you going, there are loads of extra flags that can be added. See below.

-Name <String> This is, of course, the mailbox name.
-Password <SecureString> The user’s password, stored as a SecureString meaning we cannot show it again later.
-UserPrincipalName <String> The user’s UPN name in AD, in the format username@domain.
-Alias <String> An alias, which will simplify finding the user in the GAL.
-Database <DatabaseIdParameter> The database to store the user’s mailbox.
-DisplayName <String> The user’s show name in AD.
-FirstName <String> The user’s first name.
-LastName <String> The user’s surname.
-PrimarySmtpAddress <SmtpAddress> The primary SMTP address is their email address, in the form mailbox@fqdn.
-ResetPasswordOnNextLogon <$right | $fake> Sets the flag controlling whether or not the user must change their password at next logon.
-SamAccountName <String> The user’s pre-Windows 2000 name, which is specified simply as a 15 character (or less) string.

Here are two examples of how to use this command.

Create a User and Place in OU in Powershell

This command makes an Active Directory user for John Smith in the CorpUsers OU, with a mailbox on the UserDatastore database, and an initial password that must be changed at next logon. It first prompts you for the password which it will store “-AsSecureString” meaning that it cannot be showed again.

$password = Read-Host "Enter password" -AsSecureString
New-Mailbox -UserPrincipalName -Alias john
-Database "UserDatastore" -Name JohnSmith –OrganizationalUnit
CorpUsers -Password $password -FirstName John -LastName Smith
-DisplayName "John Smith" -ResetPasswordOnNextLogon $Right

Create a resource Mailbox in Powershell and Set Password and Alias

This command makes a resource mailbox for a conference room in the CorpResources OU, using the CorpResources database, and requiring the password to be set at next logon. This sets the alias as ChaConf1, and will prompt you for the password once you hit enter.

New-Mailbox -UserPrincipalName
-Alias ChaConf1 -Name CharlotteConferenceRoom1 -Database
"CorpResources" -OrganizationalUnit ConferenceRooms -Room
-ResetPasswordOnNextLogon $Right

Create a Mailbox for an Existing User in Powershell

This command makes a mailbox for an existing user without a mailbox.

Enable-Mailbox -Identity:’ Smith'
-Alias:'JoeSmith' -Database: 'UserDatastore'

If you want to learn more about powershell consider this book.


Allen White
Allen is a Consultant for ITPS in the North East of England and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5 and HP ASE, AIS - Network Infrastructure.

ITPS provides strategic IT consultancy, implementation, data centre provision and unified communications, as well as support services and workspace and disaster recovery. If you require a consultation then please contact me via the contacts section or direct on 07931222991, add me on linkedin.


Comments (1)

  • Samuel


    Worked perfectly for somereason I had user that would show up in AD but not show up when searching in ESM GUI for mailbox creation. The Enable-Mailbox command worked perfectly for this


Leave a comment


(c) Please be aware, all information is provided freely, any information used is done so at your risk and Techieshelp will not be held responsible for any issue that may occur.
!-- BuySellAds On-Site Shopping Cart -->