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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable then delete accounts from AD using a file 1

Status
Not open for further replies.

eraH

MIS
Joined
Dec 1, 2003
Messages
106
Location
NZ
Hi,

Not sure were to start with this. I'm hoping you can point me in the right direction.

Scenario:
I have a list of users in a text file that I want to disable and then later delete. I only have the sAMaccount names.
The format of the text file is:

username1
username2
username3


How do I do this, most of the scripts I've found on the Internet point to using the distinguished name.

Thanks.
 
Use the function found in faq329-5688 to take the samAcount name and return the distinguishedName. Then you can use the standard scripts posted in Microsoft's script repository on the script center.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Sorry to ask such a basic question but how do I use the script?

BTW for anybody reading, here is how I'm going to read the TXT file.


'Starts reading the text file accountstodelete.txt
'Need to tidy up by choosing file when running script

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("accountstodelete.txt", 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Wscript.Echo strLine
Loop

objFile.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top