Skip to content

Moving mailboxes

Move a mailbox to a different mailbox store

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$targetDatabaseDN =
    "CN=DB 2,CN=Databases,CN=Exchange Administrative Group," +
    "CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange," +
    "CN=Services,CN=Configuration,DC=domain,DC=com"

# Bind to the user
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Move mailbox
$user.CreateMoveMailboxRequest("Adaxes://$targetDatabaseDN", $NULL, 0, 0)

Move a user mailbox to Microsoft 365

$Context.TargetObject.CreateMoveMailboxToO365Request("mail.mycompany.com", "mycompany.mail.onmicrosoft.com", 0, 0)  

Note

This script can be executed via Business Rules, Custom Commands, and Scheduled Tasks only. For more details, see IAdmMoveExchangeMailboxOps2.

Move a user mailbox from Microsoft 365

$Context.TargetObject.CreateMoveMailboxFromO365Request("Mailbox Database 1", "mail.mycompany.com", "mycompany.com", 0, 0)

Note

This script can be executed via Business Rules, Custom Commands, and Scheduled Tasks only. For more details, see IAdmMoveExchangeMailboxOps2.

See also