Convert Mailbox to Mail User


This script will convert an existed mailbox to a new mail user.


This script is to help Exchange Administrators to convert mailboxes to mail users via PowerShell.


This script contains one advanced function Convert-OSCMailboxtoMailUser, you can use this script in the following ways:

Step1: Run the script in the Exchange Management Shell, type the one command: Import-Module <Script Path> at the prompt.

For example, type Import-Module C:\Script\ConvertMailboxtoMailUser.psm1

Here are some code snippets for your references.

#Get Emailaddress for mailbox
$emailaddresses = $Check.EmailAddresses
$primarySmtpaddress = $Check.PrimarySmtpAddress
$userPrincipalName = $Check.UserPrincipalName
#Remove Mailbox
Remove-Mailbox $mbx -confirm:$false
#Create MailUser
New-MailUser $mbx -ExternalEmailAddress $userPrincipalName | Out-Null
#set primary smtp and secondary emailaddresses
Set-MailUser $mbx -EmailAddressPolicyEnabled $false
Set-MailUser $mbx -PrimarySmtpAddress $primarySmtpaddress
Set-MailUser $mbx -EmailAddresses $emailaddresses
Write-Host "MailUser $mbx is created."


Example 1: Convert Mailbox "Test1" to a new Mail User "Test1".
Command: Convert-OSCMailboxtoMailUser -Mailbox "Test1"

Example 2: Convert Mailboxes "Test1","Test2" to Mail Users "Test1","Test2".
Command: Convert-OSCMailboxtoMailUser -Mailbox "Test1""Test2"


Exchange 2010 and above Exchange Version
English Version only
PowerShell 2.0

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.