Solved

Problems with DSQUERY | DSMOVE command

Posted on 2007-12-03
3
1,824 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 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks oBda, very helpful.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now