delete local disabled account script

Hey everyone,

I have a server that has tons of local disabled accounts that I need to delete. I would like to automate this with a script. Can somebody provide with a script that will do this? Keep in mind that I only need the disabled accounts deleted. Thanks.
inurmixAsked:
Who is Participating?
 
deaditeCommented:
Here you go add to the IF's if there are other account exceptions you don't want deleted
strComputer = "ocnlpa-001"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
	Set objUser2 = GetObject("WinNT://" & strComputer & "/" & objUser.Name)
    If objUser2.AccountDisabled = True Then
		If objUser.Name = "Guest" Then
			'Skip
		Elseif objUser.Name = "HelpAssistant" Then
			'Skip
		Elseif InStr(objUser.Name, "SUPPORT_") > 0 Then
			'Skip
		Else
			colAccounts.Delete "user", objUser.Name
		End If
	End If
Next
Wscript.Echo "Finished"

Open in new window

0
 
Vishnu KiranPrincipal Support EngineerCommented:


Hi,

Please go though the below link and the steps recommended to run ascript from GPO to delete the accounts

http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_22643485.html

Also visit the following link for script information for deleting users.

http://www.computerperformance.co.uk/ezine/ezine134.htm

Regards,
Vishnu.
0
 
inurmixAuthor Commented:
Unfortanately this server is not part of a domain, its a stand-alone so GPO wont work or any script that binds to LDAP or Active Directory
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.