timmcmic / DLConversionV2

MIT License
44 stars 9 forks source link

Syntax errors when a distribution list name contains a single quote #52

Closed MassimoPascucci closed 2 years ago

MassimoPascucci commented 2 years ago

Just as the title says: some parts of your scripts can't handle single quotes (') in distribution list names.

Extract from the logs; please note that everything was fine up to GET-O365GroupDependency and the DL's name has been mentioned and handled several times already, so the error is not happening everywhere, just in this specific place (and possibly somewhere else after that):

[10/05/2022 16:38:08] - ********************************************************************************
[10/05/2022 16:38:08] - START RETAIN OFFICE 365 GROUP DEPENDENCIES
[10/05/2022 16:38:08] - ********************************************************************************
[10/05/2022 16:38:08] - Office 365 settings are to be retained.
[10/05/2022 16:38:08] - ********************************************************************************
[10/05/2022 16:38:08] - BEGIN GET-O365GroupDependency
[10/05/2022 16:38:08] - ********************************************************************************
[10/05/2022 16:38:08] - DN Set = CN=ANONYMIZED'WITHSINGLEQUOTE,OU=XXX,OU=Microsoft Exchange Hosted Organizations,DC=YYY,DC=PROD,DC=OUTLOOK,DC=COM
[10/05/2022 16:38:08] - Attribute Type = Members
[10/05/2022 16:38:08] - Group Type = 
[10/05/2022 16:38:08] - Attempting to search Office365 for any groups or users that have the requested dependency.
[10/05/2022 16:38:08] - Entering query office 365 for DL membership.
Exception calling "Create" with "1" argument(s): "At line:1 char:241
+ ... OUTLOOK,DC=COM') -and (isDirSynced -eq 'False') } -errorAction 'STOP'
+                                                                         ~
The string is missing the terminator: '.

At line:1 char:242
+ ... OUTLOOK,DC=COM') -and (isDirSynced -eq 'False') } -errorAction 'STOP'
+                                                                          ~
Missing closing ')' in expression.

At line:1 char:27
+ Get-o365Recipient -Filter { (Members -eq 'CN=ANONYMIZED'WITHSINGLEQUOTE ...
+                           ~
Missing closing '}' in statement block or type definition."
At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:71 char:17
+                 $scriptBlock=[scriptBlock]::create($functionCommand)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ParseException

Out-LogFile : Exception calling "Create" with "1" argument(s): "At line:1 char:241
+ ... OUTLOOK,DC=COM') -and (isDirSynced -eq 'False') } -errorAction 'STOP'
+                                                                         ~
The string is missing the terminator: '.

At line:1 char:242
+ ... OUTLOOK,DC=COM') -and (isDirSynced -eq 'False') } -errorAction 'STOP'
+                                                                          ~
Missing closing ')' in expression.

At line:1 char:27
+ Get-o365Recipient -Filter { (Members -eq 'CN=ANONYMIZED'WITHSINGLEQUOTE ...
+                           ~
Missing closing '}' in statement block or type definition."
At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:242 char:13
+             Out-LogFile -string $_ -isError:$TRUE
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Out-LogFile

Steps to reproduce: try to migrate a distribution list whose name contains a single quote.

timmcmic commented 2 years ago

I'm testing a new build now.

============================== 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: Massimo Pascucci @.> Sent: Tuesday, May 10, 2022 10:55 AM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Just as the title says: some parts of your scripts can't handle single quotes (') in distribution list names.

Extract from the logs; please note that everything was fine up to GET-O365GroupDependency and the DL's name has been mentioned and handled several times already, so the error is not happening everywhere, just in this specific place (and possibly somewhere else after that):

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - START RETAIN OFFICE 365 GROUP DEPENDENCIES

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - Office 365 settings are to be retained.

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - BEGIN GET-O365GroupDependency

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - DN Set = CN=ANONYMIZED'WITHSINGLEQUOTE,OU=XXX,OU=Microsoft Exchange Hosted Organizations,DC=YYY,DC=PROD,DC=OUTLOOK,DC=COM

[10/05/2022 16:38:08] - Attribute Type = Members

[10/05/2022 16:38:08] - Group Type =

[10/05/2022 16:38:08] - Attempting to search Office365 for any groups or users that have the requested dependency.

[10/05/2022 16:38:08] - Entering query office 365 for DL membership.

Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:71 char:17

Out-LogFile : Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:242 char:13

Steps to reproduce: try to migrate a distribution list whose name contains a single quote.

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

timmcmic commented 2 years ago

Status update.

Initial testing appears to be good. With names that can contain an ' it also means that the email address may also contain it.

I have a branch where I've fixed most of it - and am doing a full performance test now. I have no exercised the mailbox permissions code yet so that will be on this final test.

If all goes well I should have an updated build soon that fixes this.

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: Massimo Pascucci @.> Sent: Tuesday, May 10, 2022 10:55 AM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Just as the title says: some parts of your scripts can't handle single quotes (') in distribution list names.

Extract from the logs; please note that everything was fine up to GET-O365GroupDependency and the DL's name has been mentioned and handled several times already, so the error is not happening everywhere, just in this specific place (and possibly somewhere else after that):

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - START RETAIN OFFICE 365 GROUP DEPENDENCIES

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - Office 365 settings are to be retained.

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - BEGIN GET-O365GroupDependency

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - DN Set = CN=ANONYMIZED'WITHSINGLEQUOTE,OU=XXX,OU=Microsoft Exchange Hosted Organizations,DC=YYY,DC=PROD,DC=OUTLOOK,DC=COM

[10/05/2022 16:38:08] - Attribute Type = Members

[10/05/2022 16:38:08] - Group Type =

[10/05/2022 16:38:08] - Attempting to search Office365 for any groups or users that have the requested dependency.

[10/05/2022 16:38:08] - Entering query office 365 for DL membership.

Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:71 char:17

Out-LogFile : Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:242 char:13

Steps to reproduce: try to migrate a distribution list whose name contains a single quote.

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

timmcmic commented 2 years ago

Version 2.5.21 was uploaded today and should handle the special characters now.

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: Tim McMichael Sent: Wednesday, May 11, 2022 5:37 PM To: timmcmic/DLConversionV2 @.>; timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: RE: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Status update.

Initial testing appears to be good. With names that can contain an ' it also means that the email address may also contain it.

I have a branch where I've fixed most of it - and am doing a full performance test now. I have no exercised the mailbox permissions code yet so that will be on this final test.

If all goes well I should have an updated build soon that fixes this.

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: Massimo Pascucci @.**@.>> Sent: Tuesday, May 10, 2022 10:55 AM To: timmcmic/DLConversionV2 @.**@.>> Cc: Subscribed @.**@.>> Subject: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Just as the title says: some parts of your scripts can't handle single quotes (') in distribution list names.

Extract from the logs; please note that everything was fine up to GET-O365GroupDependency and the DL's name has been mentioned and handled several times already, so the error is not happening everywhere, just in this specific place (and possibly somewhere else after that):

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - START RETAIN OFFICE 365 GROUP DEPENDENCIES

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - Office 365 settings are to be retained.

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - BEGIN GET-O365GroupDependency

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - DN Set = CN=ANONYMIZED'WITHSINGLEQUOTE,OU=XXX,OU=Microsoft Exchange Hosted Organizations,DC=YYY,DC=PROD,DC=OUTLOOK,DC=COM

[10/05/2022 16:38:08] - Attribute Type = Members

[10/05/2022 16:38:08] - Group Type =

[10/05/2022 16:38:08] - Attempting to search Office365 for any groups or users that have the requested dependency.

[10/05/2022 16:38:08] - Entering query office 365 for DL membership.

Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:71 char:17

Out-LogFile : Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:242 char:13

Steps to reproduce: try to migrate a distribution list whose name contains a single quote.

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

MassimoPascucci commented 2 years ago

Works fine with single quotes, but I get the same error if a name contains double quotes.

timmcmic commented 2 years ago

Would you send me an LDP dump as an example.

According to ADUC the use of a " quote in the name of the group is not allowed. I want to see how the attributes of your groups are structured.

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: Massimo Pascucci @.> Sent: Friday, May 13, 2022 9:55 AM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Works fine with single quotes, but I get the same error if a name contains double quotes.

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F52%23issuecomment-1126082535&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TwcLuWieXEl05lWiKVllVUwonFX7GZYpzY6RHyV1ENs%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6KVRUDEK4CJ5MANP3TVJZNJ5ANCNFSM5VR4GWGA&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5b1r%2FLjnU6v%2BHRDnbvlwtuVAb6i47Jiif0aE0C4YgzI%3D&reserved=0. You are receiving this because you commented.Message ID: @.**@.>>

timmcmic commented 2 years ago

Added a line of code to modify the DN to add an escape character to double quotes.

I'll run a full test later this evening to ensure the returns of the queries are correct in the script.

============================== 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: Massimo Pascucci @.> Sent: Friday, May 13, 2022 9:55 AM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Works fine with single quotes, but I get the same error if a name contains double quotes.

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F52%23issuecomment-1126082535&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TwcLuWieXEl05lWiKVllVUwonFX7GZYpzY6RHyV1ENs%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6KVRUDEK4CJ5MANP3TVJZNJ5ANCNFSM5VR4GWGA&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5b1r%2FLjnU6v%2BHRDnbvlwtuVAb6i47Jiif0aE0C4YgzI%3D&reserved=0. You are receiving this because you commented.Message ID: @.**@.>>

MassimoPascucci commented 2 years ago

According to ADUC the use of a " quote in the name of the group is not allowed. I want to see how the attributes of your groups are structured.

Correct, the double quote is in the DN and DisplayName, not in the SAMAccountName.

The error happens when the script uses the DN, same as with the single quote.

Added a line of code to modify the DN to add an escape character to double quotes.

That should address the issue.

timmcmic commented 2 years ago

Initial testing was good. I’m waiting on the test suite script to build the full test. I should have something out this weekend pending testing.

============================== 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: Massimo Pascucci @.> Sent: Friday, May 13, 2022 12:11 PM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

According to ADUC the use of a " quote in the name of the group is not allowed. I want to see how the attributes of your groups are structured.

Correct, the double quote is in the DN and DisplayName, not in the SAMAccountName.

The error happens when the script uses the DN, same as with the single quote.

Added a line of code to modify the DN to add an escape character to double quotes.

That should address the issue.

— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F52%23issuecomment-1126223117&data=05%7C01%7Ctimmcmic%40microsoft.com%7Ce9593ab0917f4c2ae7a608da34fb4516%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880551050719098%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6IpepuUaOaIjVg9FVIlQMqh5hwK8crL8MHfcqOUBNWs%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6KUEL5N5ML2FZSNBJLVJZ5L5ANCNFSM5VR4GWGA&data=05%7C01%7Ctimmcmic%40microsoft.com%7Ce9593ab0917f4c2ae7a608da34fb4516%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880551050719098%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MpYB%2Bu%2F%2FQoSpw7uwZnkgXG8dc8aS6u0lTRcZz3WoAJo%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

timmcmic commented 2 years ago

This should now be fixed.

============================== 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: Tim McMichael Sent: Friday, May 13, 2022 10:46 AM To: timmcmic/DLConversionV2 @.>; timmcmic/DLConversionV2 @.> Cc: Comment @.***> Subject: RE: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Added a line of code to modify the DN to add an escape character to double quotes.

I'll run a full test later this evening to ensure the returns of the queries are correct in the script.

============================== 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: Massimo Pascucci @.**@.>> Sent: Friday, May 13, 2022 9:55 AM To: timmcmic/DLConversionV2 @.**@.>> Cc: Tim McMichael @.**@.>>; Comment @.**@.>> Subject: Re: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Works fine with single quotes, but I get the same error if a name contains double quotes.

- Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftimmcmic%2FDLConversionV2%2Fissues%2F52%23issuecomment-1126082535&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TwcLuWieXEl05lWiKVllVUwonFX7GZYpzY6RHyV1ENs%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKGTN6KVRUDEK4CJ5MANP3TVJZNJ5ANCNFSM5VR4GWGA&data=05%7C01%7Ctimmcmic%40microsoft.com%7C91d1b59b2ac74fc5424608da34e81fa9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637880468828439785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5b1r%2FLjnU6v%2BHRDnbvlwtuVAb6i47Jiif0aE0C4YgzI%3D&reserved=0. You are receiving this because you commented.Message ID: @.**@.>>

MassimoPascucci commented 2 years ago

Tested and works fine, thank you.

timmcmic commented 1 year ago

Confirmed - I'm working on it.

So the building of the script block to run these filtered commands is failing when the escape character is found.

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: Massimo Pascucci @.> Sent: Tuesday, May 10, 2022 10:55 AM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] Syntax errors when a distribution list name contains a single quote (Issue #52)

Just as the title says: some parts of your scripts can't handle single quotes (') in distribution list names.

Extract from the logs; please note that everything was fine up to GET-O365GroupDependency and the DL's name has been mentioned and handled several times already, so the error is not happening everywhere, just in this specific place (and possibly somewhere else after that):

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - START RETAIN OFFICE 365 GROUP DEPENDENCIES

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - Office 365 settings are to be retained.

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - BEGIN GET-O365GroupDependency

[10/05/2022 16:38:08] - ****

[10/05/2022 16:38:08] - DN Set = CN=ANONYMIZED'WITHSINGLEQUOTE,OU=XXX,OU=Microsoft Exchange Hosted Organizations,DC=YYY,DC=PROD,DC=OUTLOOK,DC=COM

[10/05/2022 16:38:08] - Attribute Type = Members

[10/05/2022 16:38:08] - Group Type =

[10/05/2022 16:38:08] - Attempting to search Office365 for any groups or users that have the requested dependency.

[10/05/2022 16:38:08] - Entering query office 365 for DL membership.

Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:71 char:17

Out-LogFile : Exception calling "Create" with "1" argument(s): "At line:1 char:241

The string is missing the terminator: '.

At line:1 char:242

Missing closing ')' in expression.

At line:1 char:27

Missing closing '}' in statement block or type definition."

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.5.20\Get-O365GroupDependency.ps1:242 char:13

Steps to reproduce: try to migrate a distribution list whose name contains a single quote.

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