Solved

Problems with DSQUERY | DSMOVE command

Posted on 2007-12-03
3
1,851 Views
Last Modified: 2010-04-21
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?
0
Comment
Question by:dbarker2
3 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 250 total points
ID: 20396698
No, that's simply a bug in dsmove; it won't read more than one line fom stdin.
Try the following workaround in a batch file (it will currently only echo the dsmove command; remove the capitalized ECHO to run it for real):

for /f "delims=" %%a in ('dsquery user -disabled "ou=contractors,dc=company,dc=corp,dc=local"') do (
  ECHO dsmove %%a -newparent "ou-disabled contractors,dc=company,dc=corp,dc=local"
)

Open in new window

0
 
LVL 26

Expert Comment

by:farhankazi
ID: 20396716
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
0
 
LVL 3

Author Closing Comment

by:dbarker2
ID: 31412364
Thanks oBda, very helpful.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question