We help IT Professionals succeed at work.

Disable and enable all users in a OU.

1,512 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

Comment
Watch Question

Brian PiercePhotographer
CERTIFIED EXPERT
Awarded 2007
Top Expert 2008

Commented:
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
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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.
Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
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
Systems Engineer
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.