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

user accounts need to delete locked out and disabled

Status
Not open for further replies.

itopman

IS-IT--Management
Mar 23, 2004
20
GB
Does any one know of away how I can delete users accounts that are not used any more, we have a sever that has several hundred accounts and about 100+ of them are no longer used these have been disabled or locked out over aperiod of time and I would like to clean up accounts.

Doing this manually will take ages is their away of using a scribt to do it.

 
You can script to delete the user accounts, I'd be very afraid of deleting locked out accounts, how are you going to determine that an account wasn't just locked out and is still an active account?




I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hi.. sorry for the delay been on leave (lucky me) You state that it can be scripted to remove these accounts and say that locked out accounts could exsist that are still in use (good point) but i am sure that these accidental locked out accounts would be very minimual compered to the number of old accounts so would not mind recreating one or two if deleted by accedent. Or a script that just takes out the disabled accounts would be a start as this is the majority that needs deleting.

But how can this be done any chance of some help here am only a network engineer not a programmer.
 
OK, I'll be happy to help you get to where you want to be. I need some info first. Are all of your users in the same OU?



I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Yes all are in the default 'Users' location

regards

Brian
 
Hi Brian, thanks for the update. I'll see what I can do to get some code to you this week unless someone else already has some. This week is a little hectic for me as I am travelling from Friday to Monday, so I may not be able to get back to you on this till next week.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
HI.. any one got any more info on this post, it is now becomming more urgent to get these user accounts cleaned up.
regards

ITOpMan
 
Hi Brian, sorry I have not forgotten you. Spent the day battling a Spoof attack. Nice welcome back after travelling for the holiday weekend. I don't currently have access to my test server so I have no code to give you yet. If anyone else has something they will hopefully post it. Otherwise I'll post ASAP.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
this is using the winnt provider which i hate but im in a hurry!!(use winnt when you know where the objects you are after are located, use adsi when you want to search or do something clever with a recordset type affair)

Set Container = GetObject("WinNT://" & DomainName)
Container.Filter = Array("user")
For Each User In Container
If User.AccountDisabled = True Then
Wscript.Echo User.Name
End If
Next

'all you need to is add/change the domainname and what you want to do with a disbled account
 
if you are serious about AD, nt domain manips, LDAP etc then buy this book
'adsi scripting for system administration'
 
Nice script MrMovie. I've been working on an LDAP version so it would do the searching.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
HI..sorry for the delay in checking this reply out but been busy taking my last couple of MCP for mcse.

I know nothing about scripting hence asking the question on this great site, what would I have to add to delete the disabled accounts found.

Perhaps do a script for disabled accounts first then locked out accounts that way I can scan through locked out accounts incase their are a few that do need to be kept.

again thanks for the reply

ITOpMan
 
If your using Windows 2003 server/AD, you can type in:

dsrm - users disabled

at a command prompt. It will search your active directory for all disabled users and remove them. This will only work with 2003 though. Otherwise, you'll have to script it, and the guys working with you already are some of the best out there.
 
HI.. unfortunately its only a 2000 server so need a script to find these objects.

ITOpMan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top