Skip to content

Commit

Permalink
Merge pull request #1873 from guruxp/apascualCTMM
Browse files Browse the repository at this point in the history
Fix for Issue 1863
  • Loading branch information
bill-long authored Nov 6, 2023
2 parents 474e67e + 4fed035 commit f1643ab
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions Admin/CrossTenantMailboxMigrationValidation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,12 @@ function CheckObjects {

#PrimarySMTP
Write-Verbose -Message "Informational: Checking if the PrimarySTMPAddress of TARGET belongs to a TARGET accepted domain"
if ($TargetTenantAcceptedDomains.DomainName -notcontains $TargetObject.PrimarySmtpAddress.Split('@')[1]) {
if ($TargetTenantAcceptedDomains.DomainName -contains $TargetObject.PrimarySmtpAddress.Split('@')[1]) {
Write-Host ">> Target MailUser PrimarySMTPAddress is part of target accepted domains" -ForegroundColor Green
} else {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant" -ForegroundColor Red -NoNewline
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant, would you like to set it to $($TargetObject.UserPrincipalName) (Y/N): " -ForegroundColor Red -NoNewline
Write-Host ">> would you like to set it to $($TargetObject.UserPrincipalName) (Y/N): " -ForegroundColor Red -NoNewline
$PrimarySMTPAddressSetOption = Read-Host
Write-Host " Your input: $($PrimarySMTPAddressSetOption)"
if ($PrimarySMTPAddressSetOption.ToLower() -eq "y") {
Expand All @@ -378,15 +381,15 @@ function CheckObjects {
} else {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant. The object is DirSynced and this is not a change that can be done directly on EXO. Please do the change on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
} else {
Write-Host ">> Target MailUser PrimarySMTPAddress is part of target accepted domains" -ForegroundColor Green
}

#EMailAddresses
Write-Verbose -Message "Informational: Checking for EmailAddresses on TARGET object that are not on the TARGET accepted domains list"
foreach ($Address in $TargetObject.EmailAddresses) {
if ($Address.StartsWith("SMTP:") -or $Address.StartsWith("smtp:")) {
if ($TargetTenantAcceptedDomains.DomainName -notcontains $Address.Split("@")[1]) {
if ($TargetTenantAcceptedDomains.DomainName -contains $Address.Split("@")[1]) {
Write-Host ">> EmailAddress $($Address) is part of the target accepted domains" -ForegroundColor Green
} else {
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: $($Address) is not part of your organization, would you like to remove it? (Y/N): " -ForegroundColor Red -NoNewline
$RemoveAddressOption = Read-Host
Expand All @@ -401,8 +404,6 @@ function CheckObjects {
Write-Host ">> Error: $($Address) is not part of your organization. The object is DirSynced and this is not a change that can be done directly on EXO. Please do remove the address from on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
}
} else {
Write-Host ">> Target MailUser ProxyAddresses are all part of the target organization" -ForegroundColor Green
}
}

Expand All @@ -411,7 +412,9 @@ function CheckObjects {
if ($SourceObject.EmailAddresses -like '*500:*') {
Write-Verbose -Message "SOURCE mailbox contains X500 addresses, checking if they're present on the TARGET MailUser"
foreach ($Address in ($SourceObject.EmailAddresses | Where-Object { $_ -like '*500:*' })) {
if ($TargetObject.EmailAddresses -notcontains $Address) {
if ($TargetObject.EmailAddresses -contains $Address) {
Write-Verbose -Message "Informational: The X500 address $($Address) from SOURCE object is present on TARGET object"
} else {
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: $($Address) is not present on the TARGET MailUser, would you like to add it? (Y/N): " -ForegroundColor Red -NoNewline
$AddX500 = Read-Host
Expand All @@ -425,8 +428,6 @@ function CheckObjects {
} else {
Write-Host ">> Error: $($Address) is not present on the TARGET MailUser and the object is DirSynced. This is not a change that can be done directly on EXO, please add the X500 address from on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
} else {
Write-Host ">> Informational: The X500 address from SOURCE object is present on TARGET object" -ForegroundColor Green
}
}
} else {
Expand Down Expand Up @@ -651,9 +652,12 @@ function CheckObjectsSourceOffline {

#PrimarySMTP
Write-Verbose -Message "Informational: Checking if the PrimarySTMPAddress of TARGET belongs to a TARGET accepted domain"
if ($TargetTenantAcceptedDomains.DomainName -notcontains $TargetObject.PrimarySmtpAddress.Split('@')[1]) {
if ($TargetTenantAcceptedDomains.DomainName -contains $TargetObject.PrimarySmtpAddress.Split('@')[1]) {
Write-Host ">> Target MailUser PrimarySMTPAddress is part of target accepted domains" -ForegroundColor Green
} else {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant" -ForegroundColor Red -NoNewline
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant, would you like to set it to $($TargetObject.UserPrincipalName) (Y/N): " -ForegroundColor Red -NoNewline
Write-Host ">> would you like to set it to $($TargetObject.UserPrincipalName) (Y/N): " -ForegroundColor Red -NoNewline
$PrimarySMTPAddressSetOption = Read-Host
Write-Host " Your input: $($PrimarySMTPAddressSetOption)"
if ($PrimarySMTPAddressSetOption.ToLower() -eq "y") {
Expand All @@ -663,17 +667,17 @@ function CheckObjectsSourceOffline {
$TargetObject = Get-TargetMailUser $TargetIdentity
}
} else {
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant. The object is DirSynced and this is not a change that can be done directly on EXO, please do the change on-premises and perform an AADConnect delta sync" -ForegroundColor Red
Write-Host ">> Error: The Primary SMTP address $($TargetObject.PrimarySmtpAddress) of the MailUser does not belong to an accepted domain on the target tenant. The object is DirSynced and this is not a change that can be done directly on EXO. Please do the change on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
} else {
Write-Host ">> Target MailUser PrimarySMTPAddress is part of target accepted domains" -ForegroundColor Green
}

#EMailAddresses
Write-Verbose -Message "Informational: Checking for EmailAddresses on TARGET object that are not on the TARGET accepted domains list"
foreach ($Address in $TargetObject.EmailAddresses) {
if ($Address.StartsWith("SMTP:") -or $Address.StartsWith("smtp:")) {
if ($TargetTenantAcceptedDomains.DomainName -notcontains $Address.Split("@")[1]) {
if ($TargetTenantAcceptedDomains.DomainName -contains $Address.Split("@")[1]) {
Write-Host ">> EmailAddress $($Address) is part of the target accepted domains" -ForegroundColor Green
} else {
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: $($Address) is not part of your organization, would you like to remove it? (Y/N): " -ForegroundColor Red -NoNewline
$RemoveAddressOption = Read-Host
Expand All @@ -685,11 +689,9 @@ function CheckObjectsSourceOffline {
$TargetObject = Get-TargetMailUser $TargetIdentity
}
} else {
Write-Host ">> Error: $($Address) is not part of your organization. The object is DirSynced and this is not a change that can be done directly on EXO, please remove the address from on-premises and perform an AADConnect delta sync" -ForegroundColor Red
Write-Host ">> Error: $($Address) is not part of your organization. The object is DirSynced and this is not a change that can be done directly on EXO. Please do remove the address from on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
}
} else {
Write-Host ">> Target MailUser ProxyAddresses are all part of the target organization" -ForegroundColor Green
}
}

Expand All @@ -698,7 +700,9 @@ function CheckObjectsSourceOffline {
if ($SourceObject.EmailAddresses -like '*500:*') {
Write-Verbose -Message "SOURCE mailbox contains X500 addresses, checking if they're present on the TARGET MailUser"
foreach ($Address in ($SourceObject.EmailAddresses | Where-Object { $_ -like '*500:*' })) {
if ($TargetObject.EmailAddresses -notcontains $Address) {
if ($TargetObject.EmailAddresses -contains $Address) {
Write-Verbose -Message "Informational: The X500 address $($Address) from SOURCE object is present on TARGET object"
} else {
if (!$TargetObject.IsDirSynced) {
Write-Host ">> Error: $($Address) is not present on the TARGET MailUser, would you like to add it? (Y/N): " -ForegroundColor Red -NoNewline
$AddX500 = Read-Host
Expand All @@ -710,10 +714,8 @@ function CheckObjectsSourceOffline {
$TargetObject = Get-TargetMailUser $TargetIdentity
}
} else {
Write-Host ">> Error: $($Address) is not present on the TARGET MailUser. The object is DirSynced and this is not a change that can be done directly on EXO, please add the address on-premises and perform an AADConnect delta sync" -ForegroundColor Red
Write-Host ">> Error: $($Address) is not present on the TARGET MailUser and the object is DirSynced. This is not a change that can be done directly on EXO, please add the X500 address from on-premises and perform an AADConnect delta sync" -ForegroundColor Red
}
} else {
Write-Host ">> Informational: The X500 address from SOURCE object is present on TARGET object" -ForegroundColor Green
}
}
} else {
Expand Down

0 comments on commit f1643ab

Please sign in to comment.