Hello,
Thank you for clarifying.
We have updated the script to meet your needs, find it below. You will not need to specify the name of the local Exchange server, it will be obtained by the script automatically.
# Get exchange server name
$homeDB = $Context.BindToObjectByDN("%homeMDB%")
$msExchOwningServerDN = $homeDB.Get("msExchOwningServer")
$msExchOwningServer = $Context.BindToObjectByDN($msExchOwningServerDN)
$remoteServer = $msExchOwningServer.DirectoryServer
$targetDeliveryDomain = "mycompany.mail.onmicrosoft.com"
$badItemLimit = "0"
$largeItemLimit = "0"
$Context.TargetObject.CreateMoveMailboxToO365Request($remoteServer, $targetDeliveryDomain, $badItemLimit, $largeItemLimit)