Disabling Accounts via Command Line

Posted on 2004-09-28
Last Modified: 2010-08-05

Does anyone know of a tool and the syntax to disable a user account in Active Directory form the command line?


Question by:stewatts
  • 2
  • 2
LVL 57

Accepted Solution

Pete Long earned 50 total points
ID: 12168333
LVL 57

Assisted Solution

by:Pete Long
Pete Long earned 50 total points
ID: 12168380

dsmod CN=username,DC=domainname,DC=com -disabled yes

Author Comment

ID: 12168398
How would I do this with the following user:

username testuser
domain itdom-tr

Many thanks
LVL 10

Expert Comment

ID: 12168676
You van use notepad and put the next script in then save it as .vbs.
Change "computername" with the computername of your server.
I don't have tried. No server 2000 here now :

'--- Disable account ADSI script ---
Set WSHShell = WScript.CreateObject("WScript.Shell")
UName = InputBox("Disable account","Username to disable : ")

Set UserObj = GetObject("WinNT://ComputerName/" & UName)
UserObj.AccountDisabled = True
Set UserObj = Nothing
'--- End Disable account ---
LVL 10

Expert Comment

ID: 12168682
The script will open an inputbox to allow you to enter a username

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 2003 Terminal Server licenses 3 349
unable to search  data in SQL 2000 server 10 304
Windows 2000 Server Pagefile.sys Error 7 649
Windows Foriegn Disk 3 136
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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