delete local disabled account script

Posted on 2009-04-24
Last Modified: 2013-11-05
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.
Question by:inurmix
    LVL 7

    Expert Comment

    by:Vishnu Kiran,ITIL,HDI SCM,CAPM


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

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


    Author Comment

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

    Accepted Solution

    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
    		Elseif objUser.Name = "HelpAssistant" Then
    		Elseif InStr(objUser.Name, "SUPPORT_") > 0 Then
    			colAccounts.Delete "user", objUser.Name
    		End If
    	End If
    Wscript.Echo "Finished"

    Open in new window


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
    This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now