Monday, 24 May 2010

Convert Linked Mailboxes to User Mailboxes in Bulk

My organisation has gone through a massive migration project to unify Active Directories and Exchange organisations. As a result of these migrations a lot of mailbox migrations have resulted in a lot of mailboxes ending up as linked mailboxes even though their not.

The official TechNet article on this explains how to disconnect the mailbox and re-attach it to the user account correctly as a user mailbox.

Another way to make this appear to be corrected is to manually change the “Recipient Type” AD property on the affected mailboxes. This though, is unsupported.

Using the official method from Microsoft results in the loss of any specific mailbox information such as SMTP, x400 & x500 addresses, mailbox sizes and any other individual mailbox settings.

Only e-mail addresses and mailbox sizes were important to me (I must admit, I forgot about mailbox sizes at first).

I came up with the script below that would properly convert all Linked Mailboxes on a particular server to user mailboxes in a supported way. The script is very effective, but you will want to check out the list of considerations below before running it, they might lead you to amend the script slightly. You will have to modify the $exchangeserver and $userdomain variables though.

$exchangeserver = "exchccr1"
$userdomain = "domain\"

$linkedmailboxes = get-mailbox -server $exchangeserver -resultsize unlimited|where {$_.recipienttypedetails -eq "LinkedMailbox"}

foreach ($mailbox in $linkedmailboxes){
Disable-Mailbox -Identity $mailbox.displayname -confirm:$false

Get-MailboxDatabase -server $exchangeserver|Clean-MailboxDatabase

start-sleep -s 90

foreach ($mailbox in $linkedmailboxes){
$usernamestring = $userdomain + $mailbox.samaccountname
Connect-Mailbox -Identity $mailbox.exchangeguid -Database $mailbox.database -User $usernamestring
set-mailbox -identity $mailbox.displayname -emailaddresses $mailbox.emailaddresses

start-sleep -s 90

foreach ($mailbox in $linkedmailboxes){
set-mailbox -identity $mailbox.displayname -EmailAddressPolicyEnabled $mailbox.EmailAddressPolicyEnabled -emailaddresses $mailbox.emailaddresses -UseDatabaseQuotaDefaults $mailbox.UseDatabaseQuotaDefaults -ProhibitSendQuota $mailbox.ProhibitSendQuota -ProhibitSendReceiveQuota $mailbox.ProhibitSendReceiveQuota -IssueWarningQuota $mailbox.IssueWarningQuota

Some things to consider…

  • The filter on this script doesn’t consider legitimate linked mailboxes.
  • Only E-Mail addresses and mailbox sizes are re-applied to the freshly attached mailbox. More can be added to the script though.
  • You can’t attach a mailbox to a disabled account. The script won’t stop, but will error on disabled user accounts.
  • Don’t stop the script as it’s running, even if it’s choosing the wrong selection of accounts. It will mean more manual work after if you do.
  • Ensure you have "Exchange Server Administrator" permissions on the server you wish to run this script.
  • Ensure you have permissions to run the Clean-MailboxDatabase permissions on the server you wish to run this script (You don't get this by default with "Exchange Sever Administrator" permissions). If you're an admin in my 0rg, we can give you this permission if you if you don't have it already.

There you go, a script that will do all your linked mailboxes in one go. I’ve not been able to find another online, so I hope this helps you.


FredBear said...

Thanks David.

With this script, I assume it is a Powershell script that will need to be run from the Exchange Management shell?

David Owen said...

Yes, this is a PowerShell script, be careful how you use it though, as you could end up with disconnected mailboxes that will loose their configuration when re-connected.



Javier said...

Hi David,

Is possible to do this bulk process in the other way?. Move normal mailbox to linked mailbox?. Is possible to do with a csv file(to do this works for example dom 10 to 10 users)

arteh said...


I am a newbie in powershell scripting and I see that get-mailbox returns information like Microsoft.Exchange.Data.MultiValuedProperty`1[System.String] : how can I get the correct information from get-mailbox (see languages for instance) how can i get the correct informations to set after with the command set-mailbox

Frank Carius said...

There is a much mor easier way with Exchange 2010 SP1

set-user -LinkedMasterAccount $null

And all the configuration is maintained

Janies said...


you mentioned that with Exchange 2010 SP1.. the "set-user -LinkedMasterAccount $null" command is much easier..

does this mean running this command will scan and convert ALL Linked Mailboxes and change them t o Regular Mailboxes?


Dennis said...

Thanks Frank, that command worked a treat. As soon as the the LinkedMasterAccount attribute was cleared, the IsLinked attribute is set to false.

Thus, the mailbox was converted from Linked to User.


If you want to convert all linked mailboxes with one PS command it would be:
Get-Mailbox -RecipientTypeDetails LinkedMailbox | Set-User -LinkedMasterAccount $null

Edwin Lloyd-Jones said...

I know this is an old article but just wanted to say thanks for this script saved me a stack load of time on our Exchange 2007 to Office 365 migration. Only part we couldn't figure out how to do was delegate permissions but so few of our users use that feature we just got them to add them back in manually