PowerShell Connect-Mailbox

PowerShell Connect-Mailbox For Exchange 2010

Here are reasons for connecting an Active Directory user object to a mailbox:

  • The original owner was somehow disconnected.
  • You want to connect a user to a second mailbox.
  • You are configuring a ‘Room’ or an ‘Equipment’ mailbox.

In each case the solution is the Connect-Mailbox cmdlet, but in each scenario you need mastery of a different PowerShell -parameter.

Topics for Exchange Connect Mailbox

 ♣

Exchange Permissions Pre-requisites

If you think about it, being able to connect a user to a  mailbox permission is a responsible task.  Thus to achieve this mapping you must be a member of these exchange groups:

  • ‘Organization Management role group’
  • ‘Server Management management role group’
    Management management is not a typo!

Instead of the EMC try this PowerShell command:

New-ManagementRoleAssignment -Role "Organization Management role" -User YourName

Understanding Connect-Mailbox

To get started, focus on just two of Connect-Mailbox’s parameters -Identity (the mailbox) and -Database (where to find this object).  Also remember that each mailbox must have a corresponding user account.

Scenario 1 Reconnect: 
Guy has been disconnected from his mailbox.

#Exchange 2010 PowerShell Script
Connect-Mailbox -Database "ExchSrv\Db1" -Identity "Guy Thomas"

Note 1:  Guy Thomas is now re-wired to his mailbox in Db1 on Exchange Server ExchSrv.

Scenario 2 Linked Mailbox: 
A linked mailbox means that it is associated with an external account, in this instance guy from cp.com.

Connect-Mailbox -Identity "GuyThomas" -Database "Mail01" -LinkedDomainController ComperfDC -LinkedMasterAccount [email protected]

Scenario 3 Room Mailbox: 
There are times when Exchange 2010 supports resources such as rooms or equipment.  This script, especially if modified to suit your organization, could complete the last step of mail-enabling a resource.

Connect-Mailbox -Identity "Boardroom" -Database "MailResource" -Room -User "Room 33"

Note 2:  For equipment resources substitute -Equipment for -Room.

Specifying the Database for Connect-Mailbox

Unless you specify the Exchange server name, the Connect-Mailbox uses the database on the local machine.  Here are values for the -Database command:

  • Server\Database
  • GUID of the database
  • Database (name)

 

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.

Connect-Mailbox Syntax

As with most PowerShell nouns, Mailbox is singular.  You can examine the parameters with this command

Get-Help Connect-Mailbox

Connect-Mailbox -Identity <StoreMailboxIdParameter> -Database <DatabaseIdParameter> [-ActiveSyncMailboxPolicy <MailboxPolicyIdParameter>] [-Alias <String>] [-Archive <SwitchParameter>] [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-ManagedFolderMailboxPolicy <MailboxPolicyIdParameter>] [-ManagedFolderMailboxPolicyAllowed <SwitchParameter>] [-User <UserIdParameter>] [-WhatIf [<SwitchParameter>]]

Note 3:  Not shown here, but there is also a -ValidateOnly parameter.

Connect-Mailbox -ValidateOnly

When you append PowerShell’s ValidateOnly parameter the command performs each action but it doesn’t actually change any mailbox properties or associations.  However, it does display a summary of the result of the validation.  Naturally, if successful you can run the command again without the ValidateOnly switch.

Connect-Mailbox -Database "ExchSrv\Db1" -Identity "Guy Thomas" -ValidateOnly

Check Mailboxes Manually with the EMCConnect-Mailbox

With PowerShell it’s often worth a walk-through in the Exchange Management Console (EMC), the benefit is you can compare the PowerShell script with what you see in the Exchange GUI.

  • Launch the EMC, navigate to the Recipient Configuration Mailbox (see right)
  • Select the disconnected mailbox you want to change.
  • Select ‘Connect’ in the right hand pane.

Other Members of the Mailbox Family of Cmdlets

Get-Command -noun Mailbox

More Examples of Mailbox Cmdlets

Note 4:  See more on PowerShell’s Connect-Mailbox.

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

The Effect of AutoDiscover on Outlook 2010

Thanks to Autodiscover, In Exchange 2010 Service Pack 1 (SP1), Outlook 2007 and 2010 clients automatically map to every mailbox to which they have Full Access permissions.

Sometimes this can be a curse, for example if Exchange Administrators are given full control of everyone’s mailbox.  If they try and open their own Outlook 2010, they will be snowed under with everyone else’s email.  Solution Administrator Guy Thomas has his own, humble, ordinary email account, and does not logon as Administrator.

Summary of Connect-Mailbox

Here are good reasons for connecting an Active Directory user to an Exchange 2010 mailbox: the original owner was disconnected, you want to connect a user to a second mailbox, or to a ‘Room’ piece of ‘Equipment’.  Remember to test your command with PowerShell’s -ValidateOnly parameter.  

While the syntax of PowerShell’s Connect-Mailbox is straightforward; you may stop and ask, ‘Am I making the right connection here?’  Giving the wrong user access to a mailbox may have repercussions within the organization.

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