How to Disable in bulk AD user account using excel

7,196

Solution 1

Using Powershell, assuming a list of usernames in a text file - one per line:

get-content d:\data\users.txt |get-aduser |set-aduser -enabled $false

Solution 2

If your Excel file contains the full LDAP path of the users, then use dsmod.

dsmod user "CN=John Doe,CN=Users,DC=microsoft,DC=com" -disabled yes

If you only have the SAM account name, then you can do a dsquery on that list and pipe that to dsmod.

In any case, you'd probably do better to work from plain text files and use BAT or PowerShell, rather than trying to parse XLS(X) files. Plain text is the scripter's friend.

Share:
7,196

Related videos on Youtube

user113784
Author by

user113784

Updated on September 18, 2022

Comments

  • user113784
    user113784 over 1 year

    How to Disable in bulk AD user account using excel for selected employees

  • user113784
    user113784 about 12 years
    using text format what will be cmd to disable selected user with same job title
  • mfinni
    mfinni about 12 years
    It seems like perhaps you're not willing to explore the tools at your disposal? Look at the documentation in dsquery user /? and dsmod user /? - and then ask questions if you get stuck.
  • user113784
    user113784 about 12 years
    Accepted checked