[Last Call] Learn how to a build a cloud-first strategyRegister Now


Disable and enable all users in a OU.

Posted on 2007-09-30
Medium Priority
Last Modified: 2008-05-31

I want a script with which i can disable all users in a OU .And a way to enable the same when required.

Is there a way to do this.


Question by:bsharath
LVL 70

Expert Comment

ID: 19986783
dsquery user ou=NameOfOU,dc=Mydomain,dc=org -limit 0 | dsmod user -disabled yes

and to enable them

dsquery user ou=NameOfOU,dc=Mydomain,dc=org -limit 0 | dsmod user -disabled no
LVL 23

Expert Comment

by:Malli Boppe
ID: 19988680
I am not sure if this works.Can you highlight all the users at once and right click to see if you get the option to disbable the users.
LVL 11

Author Comment

ID: 19990514
I get this.

C:\>dsquery user OU=CMS,OU=External Users,OU=User Accounts,OU=Countries,D
C=Development,DC=Group,DC=co -limit 0 | dsmod user -disabled yes
dsquery failed:`Users,OU=User' is an unknown parameter.
type dsquery /? for help.dsmod failed:`Target object for this command' is missin
type dsmod /? for help.
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19992384
Try this:

DSQuery user "Distinguished Name" -name * -Limit 0 |DSMod user -disabled no/yes

(To disable)
DSQuery user "OU=SALES,DC=TRAINING,DC=COM" -name * -Limit 0 |DSMod user -disabled yes

(To enable)
DSQuery user "OU=SALES,DC=TRAINING,DC=COM" -name * -Limit 0 |DSMod user -disabled no
LVL 26

Accepted Solution

Farhan Kazi earned 2000 total points
ID: 19992402

DSQuery user "Distinguished Name" -name * -Limit 0 |DSMod user -disabled no/yes
                                      ^-----OU Distinguished Name                                                      

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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