timmcmic / DLConversionV2

MIT License
44 stars 9 forks source link

Create HybridMailflow objects from Cloud only failes #58

Closed PeterNagl closed 2 years ago

PeterNagl commented 2 years ago

Hi, this one was tricky and maybe is a very special case. I need to create the hybrid mailflow objects (dynamic DL and contact) in a forest that wasn´t the source of the DL that was migrated to EXO. Maybe that is not a common use, but I think it is usefull if:

Lucky me found you function "enable-hybridMailFlowPostMigration" But it has 2 issues if there is no onprem contact and needs to create the contact from the cloud DL.

There is a call to create the contact:
new-routingContact -originalDLConfiguration $office365DLConfiguration -office365DlConfiguration $office365DLConfiguration -globalCatalogServer $globalCatalogServer -adCredential $activeDirectoryCredential -isRetry:$TRUE -isRetryOU $OU -errorAction STOP

$OriginalDLConfiguration is set to the office365DL (instead of the local AD DL) isRetry is set to $True

Issue 1) in new-routingcontact This is always executed: [string]$functionOU=Get-OULocation -originalDLConfiguration $originalDLConfiguration

OriginalDL in that scenario is a O365 group and has the OU of that group is in the cloud and not found in the local AD.

FIX: Test if isRetry is set and use the isRetryOU to point to the correct onprem OU to create the contact if ($isRetry) { [string]$functionOU=$isRetryOU } else { [string]$functionOU=Get-OULocation -originalDLConfiguration $originalDLConfiguration }

Issue 2) in new-routingcontact Script tries to extract the CN and mail attribute of the originalDLConfiguration, which normally is a onprem Object (with cn and mail), but in this case is a O365 DL without CN and without mail attribute

(possible) FIX: Check if originalDLConfiguration is a O365 group object or onprem group object

 #Check if $originalDLConfiguration is a Cloud Object, when no local contact was found
    if ($originalDLConfiguration.PsObject.Properties.name -match "IsDirSynced") {
        out-logfile -string ("cloudDL found")

        #it is a cloud DL Configuration, we use .Identity for the CN of the new contact
        [string]$functionCN=$originalDLConfiguration.Identity+"-MigratedByScript"
        $functionCN=$functionCN.replace(' ','')

it is a cloud DL Configuration, we use .WindowsEmailAddress instead of mail attribute [array]$functionProxyAddressArray=$originalDLConfiguration.WindowsEmailAddress.split("@")

    }
    else
    {
        #it is a OnPrem DL Configuration we use the CN and the mail attribute
        [string]$functionCN=$originalDLConfiguration.CN+"-MigratedByScript"
        $functionCN=$functionCN.replace(' ','')
        [array]$functionProxyAddressArray=$originalDLConfiguration.mail.split("@")        
    }
timmcmic commented 2 years ago

Phew ok - let me digest this one and get back to you.

Tim

============================== Timothy J. McMichael Senior Support Escalation Engineer @.**@.> (980)-776-7465

Hours: Sunday - Wednesday 08:00 - 16:00 eastern time zone.

Manager: Tom Roughley @.**@.>)

Premier Support - (800)-936-3100 Broad Commercial Support - (800)-936-4900

==============================

From: Peter Nagl @.> Sent: Monday, July 25, 2022 5:15 PM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] Create HybridMailflow objects from Cloud only failes (Issue #58)

Hi, this one was tricky and maybe is a very special case. I need to create the hybrid mailflow objects (dynamic DL and contact) in a forest that wasn´t the source of the DL that was migrated to EXO. Lucky me found you function "enable-hybridMailFlowPostMigration" But it has 2 issues if there is no onprem contact and needs to create the contact from the cloud DL.

There is a call to create the contact: new-routingContact -originalDLConfiguration $office365DLConfiguration -office365DlConfiguration $office365DLConfiguration -globalCatalogServer $globalCatalogServer -adCredential $activeDirectoryCredential -isRetry:$TRUE -isRetryOU $OU -errorAction STOP

$OriginalDLConfiguration is set to the office365DL (instead of the local AD DL) isRetry is set to $True

Issue 1) in new-routingcontact This is always executed: [string]$functionOU=Get-OULocation -originalDLConfiguration $originalDLConfiguration

OriginalDL in that scenario is a O365 group and has the OU of that group is in the cloud and not found in the local AD.

FIX: Test if isRetry is set and use the isRetryOU to point to the correct onprem OU to create the contact if ($isRetry) { [string]$functionOU=$isRetryOU } else { [string]$functionOU=Get-OULocation -originalDLConfiguration $originalDLConfiguration }

Issue 2) in new-routingcontact Script tries to extract the CN and mail attribute of the originalDLConfiguration, which normally is a onprem Object (with cn and mail), but in this case is a O365 DL without CN and without mail attribute

(possible) FIX: Check if originalDLConfiguration is a O365 group object or onprem group object

` #Check if $originalDLConfiguration is a Cloud Object, when no local contact was found if ($originalDLConfiguration.PsObject.Properties.name -match "IsDirSynced") { out-logfile -string ("cloudDL found")

    #it is a cloud DL Configuration, we use .Identity for the CN of the new contact

    [string]$functionCN=$originalDLConfiguration.Identity+"-MigratedByScript"

    $functionCN=$functionCN.replace(' ','')

it is a cloud DL Configuration, we use .WindowsEmailAddress instead of mail attribute [array]$functionProxyAddressArray=$originalDLConfiguration.WindowsEmailAddress.split("@")

} else {

it is a OnPrem DL Configuration we use the CN and the mail attribute

[string]$functionCN=$originalDLConfiguration.CN+"-MigratedByScript" $functionCN=$functionCN.replace(' ','') [array]$functionProxyAddressArray=$originalDLConfiguration.mail.split("@") }`

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F58&data=05%7C01%7Ctimmcmic%40microsoft.com%7C06f242aa7d3043b58ea708da6e82bd0e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637943805042249649%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FEh9OdMYa8E9Tr3UqJflwrnCbc2hjg6nr4jgsrVFvAI%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6LYY7GJYCHDGHLYJODVV37VLANCNFSM54TVNGCA&data=05%7C01%7Ctimmcmic%40microsoft.com%7C06f242aa7d3043b58ea708da6e82bd0e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637943805042249649%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ixKNO6aIyBy2WvVSjeBBRahG8ZRfzo%2BIJUCrLS%2FHH8g%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

PeterNagl commented 2 years ago

Works perfect in your last build. Thank you!