Jump to content

Recommended Posts

Posted

Hi

 

I have accounts that can only be enabled for certain lessons. I have created a powershell script and scheduled tasks to enable the accounts at the start of a lesson and then disable after. The script runs fine but every time they log on its asks them to reset their password.

Does enable/disable account force a password reset? Is there a way to stop this?

Posted

This one Disables the account

$objUser = [ADSI]"LDAP://CN=%account name%,OU=CJC,OU=Year11,OU=CA,DC=%domain%,DC=%domain%"

$objUser.put(“userAccountControl”, 514)

$objUser.SetInfo()

 

This one enables the account

$objUser = [ADSI]"LDAP://CN=%account name%,OU=CJC,OU=Year11,OU=CA,DC=%domain%,DC=%domain%"

$objUser.put(“userAccountControl”, 512)

$objUser.SetInfo()

Posted (edited)
Looks OK to me. What exactly does it say when the user logs in? Please quote verbatim, context is important here. Edited by Norphy
Posted (edited)

Although that script looks more VBScriptish than PowerShell to me. You may be better using something like this:

 

$Users = import-csv %location_of_CSV_File_with_your_users_in.csv%

$Users | ForEach {
$User = $_.UserName
Disable-ADAccount -identity $User
}

 

and

 

$Users = import-csv %location_of_CSV_File_with_your_users_in.csv%

$Users | ForEach {
$User = $_.UserName
Enable-ADAccount -identity $User
}

Edited by Norphy

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...