PowerShell New-MailboxCreate Exchange 2010 Mailboxes

Use PowerShell to Create Exchange 2010 MailboxesNew-Mailbox PowerShell Cmdlet

The first point when creating a new mailbox in Exchange 2010 is does the User Object already exist in Active Directory?  In which case you just need to Mail-Enable that user.

Alternatively, do you need an example of how to create a brand new user complete with Exchange 2010 mailbox?  In which case read on, I will explain all the steps necessary to succeed.

PowerShell New-Mailbox Example

Note that this PowerShell cmdlet uses the verb ‘New’ and these are the minimal parameters we need to supply with values in script:

OrganizationalUnit:
UserPrincipalName :
Name:
Password:

You almost always also need these parameters:
Alias, Database, Firstname, and LastName.

# Create a Mailbox with PowerShell

New-Mailbox -UserPrincipalName [email protected] `
-Alias Guy`
-Database "Mailbox Db01"`
-Name GuyThomas`
-OrganizationalUnit Users`
-Password Chang5Me`
-Firstname Guy`
-LastName Thomas`
-DisplayName "Guy Thomas"`
-ResetPasswordOnNextLogon $true

Note 1: Because I wanted to highlight the Parameters with their values I used the backtick (`) to tell PowerShell the command continues on the next line.

Here is a production version with no backticks

# Create a Mailbox with PowerShell

New-Mailbox -UserPrincipalName [email protected] -Alias Guido -Name GuidoThomas -OrganizationalUnit Users -Password Chang5Me -Firstname Guido -LastName Thomas -DisplayName "Guido Thomas"

Note 2: Once you create a mailbox enabled user you may like to check the result with the sister PowerShell cmdlet: Get-Mailbox.

Get-Mailbox -Identity "Guido Thomas"

See more about Get-Mailbox.  Another scenario is that you want to change the values, for that I would use Set-Mailbox.

Guy Recommends:  SolarWinds’ Free Bulk Mailbox Import ToolFree Download Bulk Mailbox Import Tool

Import users from a spreadsheet, complete with their mailbox.  Just provide a list of the users with the fields in the top row, and save as .csv file.  Then launch this FREE utility, match your Exchange fields with AD’s attributes, click and import the users.  Optionally, you can provide the name of the OU where the new mailboxes will be born.

There are also two bonus tools in the free download, and all 3 have been approved by Microsoft:

  1. Bulk-import new users and mailboxes into Active Directory.
  2. Seek and zap unwanted user accounts.
  3. Find inactive computers.

Download your FREE bulk mailbox import tool.

Walk-through in EMC (Exchange Management Console)New-Mailbox PowerShell cmdlet

Before I create a user and their mailbox with PowerShell I like to have a manual walk-through.  For instance, EMC, New Mailbox reminds me that Alias cannot have spaces.

  • Launch the EMC, navigate to the Recipient Configuration
  • Mailbox
  • Right-click: New Mailbox. See screenshot right

Additional Parameters for New-Mailbox

Another benefit of creating a test user manually is that it spurs me to research more parameters or user properties with PowerShell’s own Get-Help

Get-Help Get-Mailbox

Note 3: Rarely have I seen a PowerShell cmdlet with so many parameters, for example, Office, Phone and Department, to name but three.

Note 4: Even though I have used this technique many times:
Get-Help Verb-PowerShellNoun, the results never cease to surprise me for example, you could create a ‘Room’ or ‘Building’ type of Exchange 2010 mailbox.

See even more on PowerShell Mailboxes for Exchange 2010.

Where Next With Creating Exchange Mailboxes?

One of the reasons for scripting is to tackle repetitive tasks such as bulk import of users.  My approach is to break the task down in to steps.  Get each component working then bolt it all together.

  1. In this instance I would learn how to create one user with their mailbox (see above).
  2. Next I would master PowerShell’s looping techniques.
  3. Then I would investigate the best method of reading the list of users and their properties, Import-CSV or possibly Get-Content.
  4. Naturally, a key element is using PowerShell’s $Variables to build the properties of each user.

Other Members of the Mailbox Family of Cmdlets

As I have already mentioned I would start with Get-Mailbox, but there are other similar PowerShell cmdlets, research thus:

Get-Command -noun Mailbox

More Examples of Mailbox Cmdlets

Free Download of Exchange Monitor from SolarWindsGuy Recommends: The SolarWinds Exchange Monitor

Here is a free tool to monitor your Exchange Server.  Download and install the utility, then inspect your mail queues, monitor the Exchange server’s memory, confirm there is enough disk space, and check the CPU utilization.

This is the real deal – there is no catch.  SolarWinds provides this fully-functioning freebie, as part of their commitment to supporting the network management community.

Free Download of SolarWinds Exchange Monitor

Summary of Create Exchange Mailbox with PowerShell

It’s not that easy to create mail-enabled objects in PowerShell.  It takes time to master all the New-Mailbox parameters; in particular to identify all the required properties for the user.

If you like this page then please share it with your friends

 


See more PowerShell Cmdlets for Exchange 2010:

Exchange 2010 Home   • Get-ExchangeServer   • Set-ExchangeServer   • New-SystemMessage   • SP1

Get-Mailbox   • Get-MailboxStatistics   • Connect-Mailbox   • Enable-Mailbox   • Disable-Mailbox

PowerShell Exchange Cmdlets   • Set-Contact    • New-Mailcontact   • Add-MailboxPermission -identity