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

x
?
Solved

Disable and enable all users in a OU.

Posted on 2007-09-30
5
Medium Priority
?
1,350 Views
Last Modified: 2008-05-31
Hi,

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.

Regards
Sharath

0
Comment
Question by:bsharath
5 Comments
 
LVL 70

Expert Comment

by:KCTS
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
0
 
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.
0
 
LVL 11

Author Comment

by:bsharath
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
g.
type dsmod /? for help.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19992384
Try this:

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

Like:
(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
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19992402

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

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