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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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

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.
c7c4c7Author Commented:
I thought Active Directory and its components were server only.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

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.
c7c4c7Author Commented:
Take two - The userid was set to password never expires which apparently overrides the request to force the password reset
c7c4c7Author Commented:
Cannot use it in Win 8 Home, cannot force password change in Win 8 Home
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.