How to enable the user flag 'User must change password at next logon' for a local windows user?
11,681
It is possible to enable the flag 'User muat change password at next logon' through the following :
$user.passwordExpired = 1;
$user.setinfo();
Author by
cmm user
Graduate Student at Texas A & M university in MS CE. Previously worked as a software developer in Oracle India Private limited for the past 3 years. Currently working as a Software Development Engineer with Amazon Alexa.
Updated on June 14, 2022Comments
-
cmm user almost 2 years
I wanted to enable the userflag 'User must change password at next logon' through powershell scripts. For the flag Account is disable, I did the following :
$user=[ADSI]'WinNT://localhost/account23'; $user.userflags = 2; $user.setinfo();
Is it possible to add the user flag for 'User must change password at next logon' in the similar way?
-
Leelaprakash Bandi over 3 yearsThanks dudes It works well for local user in windows server data center 2019 Edition
-
Trenton McKinney over 3 yearsThe provided answer was flagged for review as a Low Quality Post. Here are some guidelines for How do I write a good answer?. This provided answer could benefit from an explanation. Code only answers are not considered "good" answers. From Review.