Udostępnij za pośrednictwem


Exchange 2010: Connect-Mailbox in a Bulk

I was working with one of my customer last week. He had a strange issue where all mailboxes for DB01 was in disconnected state. While verifying HomeMDB for these disconnected mailbox found it was missing along with few other Exchange attributes. Almost 1800+ users were impacted. Also realized 70+ AD accounts were in disabled state.

 

Customer wanted to enable all AD accounts and reconnect all mailboxes. At the time we tried reconnecting the mailbox manually using GUI it could not identify the matching user.

 

If we reset Exchange attribute for one user and try connecting the mailbox it works fine. However connecting 1800+ users manually is time consuming and it’s a huge task.

 

Plan of action to follow:

  1. List all disconnected mailbox and their alias.
  2. List all disabled AD account for disconnected mailbox and enabling them.
  3. Reset Exchange attribute for all users.
  4. Connect their mailbox back.

Note: Below tasks has to be in sequence. 

 Important: We need to be sure that none of the user has same display names. Otherwise its gonna be an issue while reconnecting the mailbox. Therefore we can list their alias and perform the task.

 1)       Export all disconnected mailbox list into csv for DB01

 

Listing all disconnected mailbox list:

 

Get-MailboxStatistics -database "DB01” | Get-Mailbox | ?{$_.Database -eq $null}| Export-Csv 'C:\Reconnecting Mailbox\db01.csv'

 

Listing these users with their alias/Import users from csv:

$all = Import-Csv 'C:\Reconnecting Mailbox\db01.csv'

$all | select DisplayName,Alias

$all | select DisplayName,Alias | Export-Csv 'C:\Reconnecting Mailbox\onlyalias.csv'

$alias = Import-Csv 'C:\Reconnecting Mailbox\onlyalias.csv'

$alias

 

2)       Listing all disabled AD accounts:

 

Get-MailboxStatistics -Database "DB01" |?{$_.DisconnectReason -eq "Disabled"}| Export-CSV "C:\AD.csv"

 

a)       Import-Module ActiveDirectory

b)       List alias for these users:

 

$all = Import-CSV "C:\AD.csv"

$n=$all | select Displayname

foreach($m in $n)

{

Get-User $m.DisplayName

}

 

 Enabling AD account for users located in different OUs however exported the list of users from mailbox database "DB01”:

 

Step1:

$g=@()

foreach($m in $n)

{

$g+= Get-User $m.DisplayName

}

 

Step2:

 

$g | %{Enable-Adaccount -Identity $_.Name

}

 

  3)       Remove Exchange attributes using RemoveExchangeattributes.ps1 for all impacted users:

Script can be obtained from: https://gallery.technet.microsoft.com/office/Remove-Exchange-Attributes-3b39b2de  

 

foreach($user in $alias)

{

$enteruser = $user.Alias

$enteruser=$user.alias

.\RemoveExchangeattributes.ps1

}

 

4)       Connect all users using below script:  

Connect all users after listing alias after importing saved csv/mailbox names (Steps are given in step 1):

 

 foreach($user in $alias)

{

connect-mailbox $user.DisplayName -user ("csxtlab\"+$user.Alias) -Database "DB01”

}

 

 Disclaimer: Please make the necessary changes as per your requirement. And highly recommended to test/verify each loop of the scripts before trying it in the production.  

 

 

Thank you,

Mukut-

Comments

  • Anonymous
    July 21, 2014
    Thanks