|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - Delete 1000 users at one time
I was playing with a script I got from the MS repository to create 1000 sample users and was wondering what I would change in it to make it delete the same 1000 users. I tried changing the objContainer.Create to objContainer.Delete and removed the two lines below it with no success. I posted the script below.
Thanks in advance Randy Set objRootDSE = GetObject("LDAP://rootDSE") Set objContainer = GetObject("LDAP://cn=Users," & _ objRootDSE.Get("defaultNamingContext")) For i = 1 To 1000 Set objLeaf = objContainer.Create("User", "cn=UserNo" & i) objLeaf.Put "sAMAccountName", "UserNo" & i objLeaf.SetInfo Next WScript.Echo "1000 Users created." |
|
#2
|
|||||
|
|||||
|
You can use this script to delete all of the users that you created.
vb Code:
If you want to learn to use ADSI effectively, you should learn by example. It's definitely worth taking the time to check out the Microsoft Scripting Guys' ADSI Scriptomatic. The MSDN also contains a great ADSI reference called the ADSI Scripting Primer. Hope this helps.
__________________
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! Last edited by Nilpo : January 12th, 2009 at 05:06 AM. |
|
#3
|
|||
|
|||
|
delete 1000 users
Thanks for the reply
When I run that I get error on line 7 char 5 no such object on the server. Any ideas Thanks Randy |
|
#4
|
||||
|
||||
|
Quote:
|
|
#5
|
|||
|
|||
|
Quote:
Thank You very much Randy |
|
#6
|
||||
|
||||
|
Quote:
I was beating my head against a wall trying to figure out why on earth that wouldn't have worked if the users existed. Thanks for the update. I glad that helped you out. |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > VBScript - Delete 1000 users at one time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|