Thursday, December 12, 2013

M$ Active Directory - Delete multiple AD users through command line

To delete multiple AD users through command line in a Active Directory Domain Controller:

1. Prepare the list of users in a text file (users.txt), one user per line:

user.txt:

user1
user2
user3


2. Open command prompt as administrator, run the following command:

for /f %i in (users.txt) do dsquery user -samid %i | dsrm -noprompt