Moving mailboxes
Move a mailbox to a different mailbox database
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.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 = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)
# Move mailbox.
$user.CreateMoveMailboxRequest("Adaxes://$targetDatabaseDN", $null, 0, 0)
Move a user mailbox to Microsoft 365
$Context.TargetObject.CreateMoveMailboxToM365Request(
"mail.mycompany.com",
"mycompany.mail.onmicrosoft.com",
0,
0)
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.CreateMoveMailboxFromM365Request(
"Mailbox Database 1",
"mail.mycompany.com",
"mycompany.com",
0,
0)
This script can be executed via business rules, custom commands, and scheduled tasks only. For more details, see IAdmMoveExchangeMailboxOps2.
See also
- Performing Exchange tasks
- IAdmMoveExchangeMailboxOps
- IAdmMoveExchangeMailboxOps2
- Writing ADSI scripts
- Server-side scripting
- Online script repository