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 jsmith@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.

 

 
 

Related Problems

Export-Mailbox and Import-Mailbox commands missing
When you try to use the powerhsell imoprt mailbox command its says the command is invalid. The same with export mailbox. Here is how to enable the import and export ...
READ SOLUTION
Delete Mail from Multiple Mailboxes
A guide on how to delete an email in multiple mailboxes in exchange 2007,Exchange 2013 and exchange 2010 sp1. How to delete an email from multiple mailboxes with ...
READ SOLUTION
You cannot mount a new Exchange Server 2010 Mailbox database
If you have just installed exchange 2010, you may find that the default datastore will not mount this is a known issue , Here is how to fix the ...
READ SOLUTION
Exchange 2010/2007 Send on Behalf , Send as.
If you want to send emails on behalf of other people then we need to setup the send as and send on behalf permissions in microsft exchange 2010 or exchange ...
READ SOLUTION
Check the amount of exchange email sent internally
A guide on how to how to check the amount of exchange email sent internally. How to check yout exchange mail internal statistics.
READ SOLUTION
The user XXX \ Administrator isn’t assigned to any management roles
Fix for [exchange2010.XXX.com] Processing data from remote server failed with the following error message. The user XXXAdministrator isn't assigned to any management roles error
READ SOLUTION
Create or Remove A Static Route In A Windows OS
If you need to route traffic in windows this can be done with a command line toll. Here is how to create a static route in windows.
READ SOLUTION
Exchange 2007/2010 Public Folders – Sub Folders
A quick guide on how to create a sub folder within public folders in exchange 2010 or exchange 2007.How to give users rights to create sub folders in public folders ...
READ SOLUTION
Export-Mailbox and Import-Mailbox commands missing
Delete Mail from Multiple Mailboxes
You cannot mount a new Exchange Server 2010
Exchange 2010/2007 Send on Behalf , Send as.
Check the amount of exchange email sent internally
The user XXX \ Administrator isn’t assigned to
Create or Remove A Static Route In A
Exchange 2007/2010 Public Folders – Sub Folders

Tags:

Allen White

Allen is a Technical Consultant for an IT company 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. Backup Academy Certified. I run this site in my spare time so if I help you then PLEASE take the time to share using the share tools on the site.

What Do You Think?

Search Solutions

Categories

(c) Techieshelp.com. 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.

If Techieshelp did not help you…

Then Microsoft will fix your problem for $99. See below on one off fixes direct from Microsoft.
Get the help you need now with a one-time support session from Answer Desk. No one knows how Microsoft software works better than our friendly and knowledgeable experts. While at home through online chat or phone, you can trust an Answer Desk expert to diagnose and solve even the toughest issue in one hour

×