Link to home
Start Free TrialLog in
Avatar of LFS IT
LFS ITFlag for United States of America

asked on

How to force users to change NT password

Hello,

Is there a way to run a script, command or something to force users to change their NT password on their next logon? We can force it by checking the box under Account tab on Users/Computers but it will be hard to do that with over 500 users.

Thank you in advance!
Avatar of becraig
becraig
Flag of United States of America image

you should be able to do this with set-aduser

Something like below should work.
What it does principally is set the flag to 0 so the user has to change their password the next time they login.
import-module ac*
gc users.csv | %{
$samaccountname = $_
Get-ADUser $samaccountname -Properties pwdLastSet   | Set-ADUser -Instance $_.pwdLastSet = 0 
}

Open in new window


One of the PS gurus could probably make this a lot cleaner but that is the idea
ASKER CERTIFIED SOLUTION
Avatar of WebDevEM
WebDevEM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can also if you have the user SAM accounts run

import-module ac*
gc users.csv | %{
$samaccountname = $_
Set-ADUser -Identity $samaccountname -ChangePasswordAtNextLogon $true
}