IAdmMoveExchangeMailboxOps2

The IAdmMoveExchangeMailboxOps2 interface provides methods for moving user mailboxes between on-premises Exchange and Microsoft 365.

Inheritance: IAdmMoveExchangeMailboxOps

To enable remote move migrations, you need to have an externally accessible Exchange server with configured Client Access role and the Mailbox Replication Service Proxy (MRSProxy) service running.

The IAdmMoveExchangeMailboxOps2 interface is available on the server side only. Thus, methods of the interface can be used only in scripts executed via business rules, custom commands, and scheduled tasks.

To move mailboxes within on-premises Exchange, use the IAdmMoveExchangeMailboxOps interface.

Methods

Details

CreateMoveMailboxToM365Request()

Creates a request for moving a user mailbox from on-premises Exchange to Microsoft 365. The method moves mailboxes asynchronously, meaning that its call will return before the mailbox move is complete.

void CreateMoveMailboxToM365Request(string mrsProxyHostName,
                                    string targetDeliveryDomain,
                                    int badItemLimit, 
                                    int largeItemLimit)

Parameters

  • mrsProxyHostName - Specifies the complete domain name of an externally accessible on-premises Exchange server that facilitates remote move migrations between Microsoft 365 and local Exchange. The on-premises Exchange server should have the Client Access role configured and the Mailbox Replication Service Proxy (MRSProxy) service running.
  • targetDeliveryDomain - Specifies the name of a Microsoft 365 domain used for mail routing. After a mailbox is moved, the user becomes mail-enabled in local Exchange, and their mail is routed to the specified Microsoft 365 domain.
  • badItemLimit - Specifies the maximum number of bad items that are allowed before the request fails. A bad item is a corrupt item in the source mailbox that can't be copied to the target mailbox. Use 0 to not skip bad items. The valid input range for this parameter is from 0 through 2147483647.
  • largeItemLimit - Specifies the number of large items to skip if the request encounters such items in the mailbox. A large item is a message in the source mailbox that exceeds the maximum message size that's allowed in the target mailbox. Use 0 to not skip any large items.

Examples

The following code sample moves a local mailbox to Microsoft 365.

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

CreateMoveMailboxFromM365Request()

Creates a request for moving a user mailbox from Microsoft 365 to on-premises Exchange. The method moves mailboxes asynchronously, meaning that its call will return before the mailbox move is complete.

void CreateMoveMailboxFromM365Request(string remoteTargetDatabase, 
                                      string mrsProxyHostName, 
                                      string targetDeliveryDomain, 
                                      int badItemLimit, 
                                      int largeItemLimit)

Parameters

  • remoteTargetDatabase - Specifies the name of the database in the on-premises Exchange server to move the mailbox to.
  • mrsProxyHostName - Specifies the complete domain name of an externally accessible on-premises Exchange server that facilitates remote move migrations between Microsoft 365 and local Exchange. The on-premises Exchange server should have the Client Access role configured and the Mailbox Replication Service Proxy (MRSProxy) service running.
  • targetDeliveryDomain - Specifies the on-premises target delivery domain. After a mailbox is moved, the user becomes mail-enabled in Microsoft 365, and their mail is routed to the specified domain.
  • badItemLimit - Specifies the maximum number of bad items that are allowed before the request fails. A bad item is a corrupt item in the source mailbox that can't be copied to the target mailbox. Use 0 to not skip bad items. The valid input range for this parameter is from 0 through 2147483647.
  • largeItemLimit - Specifies the number of large items to skip if the request encounters such items in the mailbox. A large item is a message in the source mailbox that exceeds the maximum message size that's allowed in the target mailbox. Use 0 to not skip any large items.

Examples

The following code sample moves a mailbox from Microsoft 365 to on-premises Exchange.

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

Requirements

Minimum required version: 2023

See also