I am just passing by, having issues with cross-tenant migration as well but different problem. I am by no means an expert on this subject, but I think your issue is that your are creating "contacts" when you should be creating mailuser's using new-mailuser
cmdlet. See the example code near the bottom of the article you've linked in your original post. You must export specific information from the source usermailbox, import it into another powershell session that is connected to the target tenant, then create mailuser's with all of the attributes taken from the export.
# From the source tenant, test with a specific user "mytest"
$users = get-user -filter 'userprincipalname -eq "******@mydomain.onmicrosoft.com"' | % {
get-mailbox $_.userprincipalname | select-object `
primarysmtpaddress,
alias,
samaccountname,
firstname,
lastname,
displayname,
name,
exchangeguid,
archiveguid,
legacyexchangedn,
emailaddresses
}
$users | export-clixml ~\Desktop\test_users.xml
# From the target tenant, create your "mytest" mailuser
$users = import-clixml ~\Desktop\test_users.xml
foreach($mailbox in $users){
# Setup target MailUser attributes
$mosi = $mailbox.alias, 'target0.onmicrosoft.com' -join '@'
$password = 'changeMe!!!1890' # set static password while testing
$x500 = 'x500', $mailbox.legacyexchangedn -join ':'
$mailuser_attr = @{
microsoftonlineservicesid = $mosi
primarysmtpaddress = $mosi
externalemailaddress = $mailbox.primarysmtpaddress
firstname = $mailbox.firstname
lastname = $mailbox.lastname
name = $mailbox.name
displayname = $mailbox.displayname
alias = $mailbox.alias
password = $password | convertto-securestring -asplain -force
}
# Create target MailUser
$mailuser = new-mailuser @mailuser_attr
$mailuser | set-mailuser `
-emailaddresses @{add=$x500} `
-exchangeguid $mailbox.exchangeguid `
-archiveguid $mailbox.archiveguid
# Add X500 addresses
$temp_x500 = $mailbox.emailaddresses | where-object { $_ -match 'x500' }
$temp_x500 | foreach-object {
set-mailuser $mailbox.alias -emailaddresses @{add="$_"}
}
}
Doing this has worked for me, I do not get errors about missing mailuser on the target side. Also my Test-MigrationServerAvailability
comes back successful.
That said, I am having my own issuing during migration, error states that the source user (hybrid mailbox in exchange online) is in some sort of hold when it's really not, and there is no retention policy applied, so perhaps I'm doing something wrong in the code above, but may be a step closer for you. And who knows, maybe you will not run into the hold issue I'm having.
Hope that helps.