The below script can be used to recreate a mailbox in Exchange. This has been useful because we had an issue where we had to do this for an entire business as recommended by Microsoft because they moved from on premises Exchange to Office 365 then were upgraded/downgraded to a different version of on premises Exchange.
The script does the below tasks:
- Gets the user details
- Exports user groups
- Gets user OU
- Gets mailbox database
- Exports calendar permissions
- Exports mailbox permissions
- Exports send as permissions
- Gets email addresses and whether hidden from address lists
- Gets permissions the user had on other mailboxes
- Gets send as permissions the user had on other mailboxes
- Gets calendars that the user had access to
- Exports email to PST
- Recreates user account
- Re-assigns all above permissions
- Re-assigns all email addresses
- Imports email from PST
Run the script as below. NB, you need to create a share with read/write permissions for the Exchange Trusted Subsystem to be used by the mailbox export process.
.Recreate-Mailbox.ps1 -Mailboxes user1,user2,user3 -TempPSTLocation \localhosttemp$ -ExchangeServer Server1
The script can be downloaded here: https://gallery.technet.microsoft.com/exchange/Recreate-mailbox-on-084b663f