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 email@example.com -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 CharlotteConferenceRoom1@example.com -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:’example.com/CorpUsers/Joe Smith' -Alias:'JoeSmith' -Database: 'UserDatastore'
If you want to learn more about powershell consider this book.