Link to home
Start Free TrialLog in
Avatar of Donald Barker
Donald BarkerFlag for United States of America

asked on

Problems with DSQUERY | DSMOVE command

I am attempting to move disabled users from one ou to another using the following command and I keep getting an error.

dsquery user -disabled "ou=contractors,dc=company,dc=corp,dc=local" | dsmove -newparent "ou-disabled contractors,dc=company,dc=corp,dc=local"

dsmove failed:`CN=Smith\, John,OU=Contractors,DC=COMPANY,DC=Corp,DC=Local' is an unknown parameter.

It seems that dsmove is reading the "\" as a backslash instead of using it as an escape character. as required according to dsmove help.

Can someone explain to me how to correct this problem, or perhaps a better way of performing this task?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

Click Start -> Run -> Cmd.exe -> OK

FOR /F "delims=*" %u IN ('DSQuery User -disabled "ou=contractors,dc=company,dc=corp,dc=local"') DO @DSMove %u -NewParent "ou-disabled contractors,dc=company,dc=corp,dc=local"

Hope this helps!
Farhan
Avatar of Donald Barker

ASKER

Thanks oBda, very helpful.