+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Disable AD user accounts in Coding and Web Development; I need a batch file to disable user accounts of students that have now left the school. I only have ...
  1. #1

    Join Date
    Feb 2011
    Posts
    64
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Disable AD user accounts

    I need a batch file to disable user accounts of students that have now left the school.

    I only have the student's login number and we have these students setup in different OU's. The student number is the username.

    How can I search AD and disable the account without needing the nested OU?

    Many thanks

  2. #2
    ADMaster's Avatar
    Join Date
    May 2012
    Posts
    337
    Thank Post
    5
    Thanked 35 Times in 30 Posts
    Rep Power
    23
    Powershell is the way to go here this can be done with just a few lines.

    What OS is your server, do you have access to Microsoft's adcmdlets
    Active Directory Cmdlets in Windows PowerShell

    If not Quest AD cmdlets will work as well

    Also bulkadusers by wisesoft will be a great tool for this, you can load users by list of usernames.
    Bulk AD Users
    Here is a rough outline off the top of my head, you will need to adjust syntax etc.

    Cheers

    Code:
    $userfile = import-csv pathtooldusers.csv
    for each ($user in $userfile) 
    {
    $aduser = get-aduser $user
    set-aduser -identity $aduser -enabled 0 -Description "disabled by script" 
    }
    echo "done"
    
    
    

  3. Thanks to ADMaster from:

    rpettit (26th August 2014)

  4. #3

    Join Date
    Feb 2011
    Posts
    64
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Thanks for the quick reply.

    Running server 2012 R2.

    I'll give wisesoft a go.

    Thanks for the syntax example

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 4
    Last Post: 4th October 2011, 12:59 PM
  2. Network Printers automatically added to user accounts
    By Olliegami in forum Windows Server 2000/2003
    Replies: 6
    Last Post: 9th June 2010, 12:23 PM
  3. AD User Accounts Not Inheriting Permissions
    By OutLawTorn in forum Windows Server 2000/2003
    Replies: 0
    Last Post: 19th October 2009, 10:56 PM
  4. AD User account problems!!!
    By Athlona in forum Wireless Networks
    Replies: 16
    Last Post: 27th October 2008, 08:30 PM
  5. User account disabled - who did it?
    By kennysarmy in forum Windows
    Replies: 10
    Last Post: 3rd March 2008, 05:25 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •