rpettit Posted July 20, 2014 Posted July 20, 2014 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
ADMaster Posted July 20, 2014 Posted July 20, 2014 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 $userfile = import-csv pathtooldusers.csv for each ($user in $userfile) { $aduser = get-aduser $user set-aduser -identity $aduser -enabled 0 -[i]Description "disabled by script" } echo "done" [/i] 1
rpettit Posted July 20, 2014 Author Posted July 20, 2014 Thanks for the quick reply. Running server 2012 R2. I'll give wisesoft a go. Thanks for the syntax example
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now