timmcmic / DLConversionV2

MIT License
44 stars 9 forks source link

null-valued expression error with nested Groups #56

Closed PeterNagl closed 2 years ago

PeterNagl commented 2 years ago

Hi again,

I am using version 2.0.5. When I try to migrate a DL that is member of a different DL it stops with error:

[13.07.2022 14:32:43] - Gathering the AD object based on distinguished name.
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.22\Get-CanonicalName.ps1:100 char:13
+             $functionDomain=$functiontest.canonicalName.split("/")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

This is pointing to an issue in Get-CanonicalName.ps1 LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -errorAction STOP

When I try the same command from a new PowerShell session, I also get an error because get-adobject is searching in the Domain of the client I am running the script off and not the Domain where the Group is located.

Get-CanonicalName.ps1 receives a parameter for $globalCatalogServer but never us it.

I fixed the issue in my local version by pointing get-adobject to the GC LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -Server $globalCatalogServer -errorAction STOP

Maybe you also want to test in LINE100 if $functionTest has a value.

kind regards Peter

timmcmic commented 2 years ago

Please submit the full log to @.**@.>

Dlconversionv2 at service dot microsoft dot com

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: Wednesday, July 13, 2022 10:04 AM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] null-valued expression error with nested Groups (Issue #56)

Hi again,

I am using version 2.0.5. When I try to migrate a DL that is member of a different DL it stops with error:

[13.07.2022 14:32:43] - Gathering the AD object based on distinguished name.

You cannot call a method on a null-valued expression.

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.22\Get-CanonicalName.ps1:100 char:13

This is pointing to an issue in Get-CanonicalName.ps1 LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -errorAction STOP

When I try the same command from a new PowerShell session, I also get an error because get-adobject is searching in the Domain of the client I am running the script off and not the Domain where the Group is located.

Get-CanonicalName.ps1 receives a parameter for $globalCatalogServer but never us it.

I fixed the issue in my local version by pointing get-adobject to the GC LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -Server $globalCatalogServer -errorAction STOP

Maybe you also want to test in LINE100 if $functionTest has a value.

kind regards Peter

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

PeterNagl commented 2 years ago

Hi Tim, after fixing the issue, I migrated all groups without a problem and deleted the FAILED logs. Next week we will do another Batch of Groups and I can generate new Logs. kind regards Peter

timmcmic commented 2 years ago

Peter

What did you fix? That might help me isolate this some…

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: Friday, July 15, 2022 6:05 PM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] null-valued expression error with nested Groups (Issue #56)

Hi Tim, after fixing the issue, I migrated all groups without a problem and deleted the FAILED logs. Next week we will do another Batch of Groups and I can generate new Logs. kind regards Peter

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F56%23issuecomment-1185983452&data=05%7C01%7Ctimmcmic%40microsoft.com%7C16408e52137a42a94e0608da66ae2d28%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935195516144650%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=o4m98wgJiBLbfGf%2FYPurTc%2FWSHxLmbFsWYLznyAYKTM%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6ISCB7BIWSTHNIRU7TVUHODZANCNFSM53O3FCEQ&data=05%7C01%7Ctimmcmic%40microsoft.com%7C16408e52137a42a94e0608da66ae2d28%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935195516144650%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=U4PALZI2p2oBBUN%2BSsLSbxI075uXj3nW%2Fhpd%2FkAlEDw%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

PeterNagl commented 2 years ago

I fixed the issue in my local version by pointing get-adobject to the GC in Get-CanonicalName.ps1 LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -Server $globalCatalogServer -errorAction STOP

Without specifying the GC the command tries to lookup the Group in the local Forest (which is not the Exchange Forest). I will get you the logfiles for sure.

Peter

timmcmic commented 2 years ago

Peter:

So that I understand the scenario.

You're running the script from a machine that's in your account forest - but you're migrating a group that comes from a different exchange resource forest?

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: Saturday, July 16, 2022 7:19 AM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] null-valued expression error with nested Groups (Issue #56)

I fixed the issue in my local version by pointing get-adobject to the GC in Get-CanonicalName.ps1 LINE69 $functionTest = get-adobject -filter {distinguishedname -eq $dn} -properties canonicalName -credential $adCredential -Server $globalCatalogServer -errorAction STOP

Without specifying the GC the command tries to lookup the Group in the local Forest (which is not the Exchange Forest). I will get you the logfiles for sure.

Peter

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F56%23issuecomment-1186156944&data=05%7C01%7Ctimmcmic%40microsoft.com%7Cb9acf32053c847f0c87b08da671cf48f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935671315069901%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SVgULtz3t5yIxLoGZjvclzkO%2BQORawpmMSWkCdGE%2BbI%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6OVJYBCKJYJZHEJIWTVUKLBRANCNFSM53O3FCEQ&data=05%7C01%7Ctimmcmic%40microsoft.com%7Cb9acf32053c847f0c87b08da671cf48f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935671315069901%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CAbs9KQqOfxSWNN%2Fu6eCF%2Fcgu8chyGbwZOnoEPyDUWo%3D&reserved=0. You are receiving this because you commented.Message ID: @.**@.>>

PeterNagl commented 2 years ago

I run the migration on the AD Connect Server, which is member of one forest (A) out of 7 forests and all are Exchange Hybrid to the same Tenant. You are correct, the issue happens when I migrate a DL of a different forest (eg. B). Server that runs the migration module = Forest A AD Connect Server = Forest A Exchange Server = Forest B GC = Forest B

I could, of course run the migration script in Forest B, but then I need to switch migration server all the time. But since I put the GC into get-adobject, all works well. The function "get-canonicalName" even has a parameter for the GC, but it is not used in the function (so far).

Function get-canonicalName { [cmdletbinding()]

    Param
    (
        [Parameter(Mandatory = $true)]
        [string]$globalCatalogServer,
        [Parameter(Mandatory = $true)]
        [string]$DN,
        [Parameter(Mandatory = $true)]
        $adCredential
    )

kind regards Peter

timmcmic commented 2 years ago

Ok - there was someone else who pointed out an inefficiency here a few weeks ago. I’m going to go ahead and revert a code change and change the code to a gc call on port.

I’ll let you know when the build is up to test.

============================== 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: Saturday, July 16, 2022 3:23 PM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] null-valued expression error with nested Groups (Issue #56)

I run the migration on the AD Connect Server, which is member of one forest (A) out of 7 forests and all are Exchange Hybrid to the same Tenant. You are correct, the issue happens when I migrate a DL of a different forest (eg. B). Server that runs the migration module = Forest A AD Connect Server = Forest A Exchange Server = Forest B GC = Forest B

I could, of course run the migration script in Forest B, but then I need to switch migration server all the time. But since I put the GC into get-adobject, all works well. The function "get-canonicalName" even has a parameter for the GC, but it is not used in the function (so far).

Function get-canonicalName { [cmdletbinding()]

Param
(
    [Parameter(Mandatory = $true)]
    [string]$globalCatalogServer,
    [Parameter(Mandatory = $true)]
    [string]$DN,
    [Parameter(Mandatory = $true)]
    $adCredential
)

kind regards Peter

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F56%23issuecomment-1186271772&data=05%7C01%7Ctimmcmic%40microsoft.com%7Cf45be2ac81f54c552f7e08da6760acdb%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935962161635403%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=G7XgCiaD1W6m1MLqIqdzzh1eFJwirZpqjZkPjGxzDiA%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6MDCZ2N375ZEBOXDZTVUMD3LANCNFSM53O3FCEQ&data=05%7C01%7Ctimmcmic%40microsoft.com%7Cf45be2ac81f54c552f7e08da6760acdb%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637935962161635403%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RvbfZwHGUHw%2B8Ad0RwYIt3ZBL%2F9pXTj9DyNBnIGI%2FGs%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

PeterNagl commented 2 years ago

Sounds great, thank you!

timmcmic commented 2 years ago

Peter:

If you download the following branch zip file.

timmcmic/DLConversionV2 at RefineADCalls (github.com)https://github.com/timmcmic/DLConversionV2/tree/RefineADCalls

Expand the zip file to a folder.

Navigate powershell to the folder.

Unblock-file *

Import-module dlconversionv2 -force

Then try - this has the updated GC with port reference in get-canonicalName.

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: Sunday, July 17, 2022 12:47 PM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] null-valued expression error with nested Groups (Issue #56)

Sounds great, thank you!

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F56%23issuecomment-1186565156&data=05%7C01%7Ctimmcmic%40microsoft.com%7C832020fb9d5b424e03f808da6813fa4f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637936732261962365%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2BEJ7vlnuWDSmGLRBrRYvnN4B%2FBHAY5AtdS5654tppgE%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6OT6DVEF3ALRM2YDP3VUQ2IPANCNFSM53O3FCEQ&data=05%7C01%7Ctimmcmic%40microsoft.com%7C832020fb9d5b424e03f808da6813fa4f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637936732261962365%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6y4VsI%2BWSA5qh7fe%2FwMXGBr5W0d7CxPMHEBi1yjT%2FlA%3D&reserved=0. You are receiving this because you commented.Message ID: @.**@.>>

PeterNagl commented 2 years ago

Hi Tim, just want to say that I still was not able to test the new build in production because I need to fix 2 other issues that came up in that project. By solving this 2 issues I found 2 other Issues in DLConversionV2 which I will post shortly.