• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

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.
0
inurmix
Asked:
inurmix
1 Solution
 
Vishnu KiranCommented:


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
 
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

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now