itgeek2008 Posted September 30, 2014 Posted September 30, 2014 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?
strawberry Posted September 30, 2014 Posted September 30, 2014 Sounds like its expired then. Either change it or set it to never expire in AD.
itgeek2008 Posted September 30, 2014 Author Posted September 30, 2014 have already done that, but each time it ask for a new password
Norphy Posted September 30, 2014 Posted September 30, 2014 Post your script and let's have a look at what it's doing.
itgeek2008 Posted September 30, 2014 Author Posted September 30, 2014 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()
Norphy Posted September 30, 2014 Posted September 30, 2014 (edited) Looks OK to me. What exactly does it say when the user logs in? Please quote verbatim, context is important here. Edited September 30, 2014 by Norphy
Norphy Posted September 30, 2014 Posted September 30, 2014 (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 September 30, 2014 by Norphy
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