Jump to content

Recommended Posts

Posted

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

Posted

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]

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...