Convert Mailbox to Mailuser

I was asked to convert a mailbox to a mailuser, and funny enough although the reverse is true, you can’t just call enable-mailuser on a mailbox…

Of course you can disable-mailbox and then enable-mailuser but that removes all Exchange related attributes, which isn’t really that desirable.  To overcome this I wrote a small script that will do the conversion for you and keep the pertinent attributes.

The script takes the following parameters

  • Identity: which mailbox are you looking to convert
  • ExternalEmailAddress: where do you want mail for this mailuser to go
  • DomainController: optional, but forces all operations to be done on the same DomainController

If you want to preserve other attributes it is trivial to update the script to do so. After the following line just add whichever other attributes you want to retain

$parameters.add( 'CustomAttribute15', $OldMailbox.CustomAttribute15 )

 

So just a quick post today, but hopefully a useful one

*** As always the script is provided on an as is basis, please test it before you use it in a production environment. ***

Convert-MailboxToMailuser.ps1

Twan van Beers

Twan is a senior consultant with over 20 years of experience. He has a wide range of skills including Messaging, Active Directory, SQL, Networking and Firewalls. Twan loves to write scripts and get deep and dirty into debugging code, in order to understand and resolve the most complex of problems.

This Post Has 6 Comments

  1. Twan

    I tried your script and it works well for individual users. I have been trying to write an additional script to make it import the Identities, email address and domain controller from a csv file without success.
    can you help me with this?

    1. Hi Milton,

      you would need to use something like the following where your csv has headings identity, domaincontroller and externalemailaddress

      import-csv .\csvfile.csv | foreach-object { .\Convert-MailboxToMailuser.ps1 -identity $_.Identity -DomainController $_.DomainController -ExternalEmailAddress $_.ExternalEmailAddress }

      Regards
      Twan

    1. Twan,
      Just one more thing. The script is running but I have to confirm each addition.
      How can I automatically confirm – yes to all.
      I select that when it comes up but it still stops at each.

      Thanks
      Milton

      1. Hi Milton,

        You should be able to add -Confirm:$False

        import-csv .\csvfile.csv | foreach-object { .\Convert-MailboxToMailuser.ps1 -identity $_.Identity -DomainController $_.DomainController -ExternalEmailAddress $_.ExternalEmailAddress -Confirm:$False }

        Regards
        Twan

Leave a Reply

Your email address will not be published. Required fields are marked *

Search