0

I am testing group migration using ADMT cmd line, but the migration is failing for a specific case when the OU name contains double quotes.

ADMT GROUP /n "TestGroup" /sd:Child.A.COM /sdc.CHILD.A.COM /td.COM /tdc.A.COM /to:"ParentOU/TEST!@#$%^&*()_+{}|:"<>?[]\;',./" /intraforest:yes

In cmd this throws "> was unexpected at this time" and in powershell it keeps waiting for more parameters. The main purpose is to convert this to a c# script the migrates the users/groups but it failed in the testing phase with cmd/powershell. Is there any way to make this possible at least in C#?

I have tried escaping the double quotes with "", ^", ", `" but nothing seems to work. I have also tried assigning the value to a variable and using the variable in powershell. Using "" (as suggested in this Escaping special characters in cmd) is the only time the command runs but it still throws the following error.

Error: Unable to migrate groups. Unable to bind to container 'ParentOU/TEST!@#$%^&()+{}|:<>?[];',./ /intraforest:yes'. Unable to get distinguished name for 'A.COM/ParentOU/TEST!@#$%^&;()+{}|:<>?[];',./ /intraforest:yes'. : The parameter is incorrect. (0x80070057)

The same is working if I create another OU with same name except for the double quotes.

Please help in resolving this issue.

jeb
  • 78,592
  • 17
  • 171
  • 225

1 Answers1

0

You can do solve it in different ways:

With escaping the characters with carets outside of the quote

setlocal EnableDelayedExpansion
set "to_param=ParentOU/TEST^!@#$%^&*()_+{}|:"^^^^^<^^^^^>?[];',./"
call ADMT GROUP /to:"%%to_param%%"

The main problem will be the ADMT program, you need to know how it parses the arguments, particularly with regard to the rules how it escape quotes inside arguments.
You could test \" in set "to_param=ParentOU...\"^^^^^<^^^^^>?[];',./"

jeb
  • 78,592
  • 17
  • 171
  • 225
  • Unfortunately this still throws '> was unexpected at this time' error. I did try \" before and even with your suggestion it throws '> was unexpected at this time' error after set "to_param" command. I will try gather more info regarding how ADMT parses arguments. Thank you... – Ammu Shiri K Nov 29 '22 at 11:50