Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to remove all the users of a OU ? 1

Status
Not open for further replies.

srenshaw

IS-IT--Management
Jan 19, 2005
75
CA
We're currently writing/testing a program that create a lot of users in a specific OU from an Excel sheet.

To speed up the testing, we only uses the first five users. I made a quick .bat that remove each user using "net user <user> /delete /domain". That is good for 5 users. Not so for a hundred.

I don't think I can use "net user" to select every users in a OU.

could a .vbs do the trick ?

Any suggestions ?

Thanks !
 
Why not simply highlight all of the users in the GUI and hit delete?

I hope you find this post helpful.

Regards,

Mark
 
If I were in the same position, I would firstly export the list of 100 users you wish to remove with full dsn to a text file.

Then write a simple batch file which uses the FOR /F statement. This statement will execute your NET USE command for every user in the text file list created earlier.

Alternatively you can use CSVDE to export all the users to a spreadsheet and LDIFDE to delete all the objects within the spreadsheet.

....Or move all your users to one OU and use "DSQUERY 'ou=..,dc=..,dc=..' -users|DSRM" to remove all objects within the OU.

I hope this is of some use....it all depends on your preference. If you prefer using NET USE then you probably will have to combine with the FOR /F statement.
 
Thanks Roeee, this is wxactly what I was looking for !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top