Escape and preserve double quotes inside OU parameter in admt command

Ammu Shiri Krishnan 1 Reputation point
2022-11-29T08:53:29.333+00:00

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.

Cmd: ADMT GROUP /n "TestGroup" /sourcedomain:Child.A.COM /sourcedomaincontroller:DC2.CHILD.A.COM /targetdomain:A.COM /targetdomaincontroller:DC1.A.COM /targetou:"ParentOU/TEST!@#$%^&*()_+{}|:"<>?[]\;',./" /intraforest:yes /migratesids:yes /migratemembers:no /fixgroupmembership:yes

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

I have tried escaping the double quotes with "", ^", \", `" but nothing seems to work. The same is working if I create another OU with same name except for the double quotes.

Please help in resolving this issue.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,906 Reputation points
    2022-11-29T15:47:30.19+00:00

    Shell quoting is always a problem. What are you using as a shell, CMD.com or PowerShell.exe? Since you have a windows-server-powershell tag in your question, I'll assume it's PowerShell.

    Try placing a back-tick character before the interior double-quote, or put the targetou value into a variable and using the back-tick in the string value. Then use the variable as the targetou value:

    $p = "ParentOU/TEST!@#$%^&*()_+{}|:`"<>?[]\;',./"  
      
    ADMT GROUP /n "TestGroup" /sourcedomain:Child.A.COM /sourcedomaincontroller:DC2.CHILD.A.COM /targetdomain:A.COM /targetdomaincontroller:DC1.A.COM /targetou:"$p" /intraforest:yes /migratesids:yes /migratemembers:no /fixgroupmembership:yes  
    

    You may have to experiment with the number of double-quotes surrounding the targetou value as each pass through a shell removes one level of quotations.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.