Powershell script to force password change

Using Powershell, on a win 7 pro and Win8 home machine, workgroup not a domain, how do I force a user to change their password?

Please include the code
c7c4c7Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
this will set the flag to change the password:
$usr=[ADSI]'WinNT://localhost/TheUserLogonName'  
$usr.passwordExpired = 1  
$usr.setinfo()  

Open in new window

HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Will SzymkowskiSenior Solution ArchitectCommented:
You can also reference some examples for this on powershell.com. See link below...
http://powershell.com/cs/forums/t/15101.aspx

Will.
0
c7c4c7Author Commented:
I thought Active Directory and its components were server only.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

c7c4c7Author Commented:
The code supplied
$usr=[ADSI]'WinNT://localhost/TheUserLogonName'  
$usr.passwordExpired = 1  
$usr.setinfo()  

On Win 7 Pro although it does not flag any error does not require the user to reset their password, I did replace the TheUserLogonName with the correct user name.
0
c7c4c7Author Commented:
Take two - The userid was set to password never expires which apparently overrides the request to force the password reset
0
c7c4c7Author Commented:
Cannot use it in Win 8 Home, cannot force password change in Win 8 Home
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.