We help IT Professionals succeed at work.

Interactive Powershell script to reset password age in AD

744 Views
Last Modified: 2017-03-20
I am looking for a script to reset the password age for a specific useraccount in our AD. I found the script that makes this happen:

$User = Get-ADUser username -properties pwdlastset 
$User.pwdlastset = 0 
Set-ADUser -Instance $User 
$user.pwdlastset = -1 
Set-ADUser -instance $User

Open in new window


Wat i need is a way for our helpdesk to use this script without having to change the username everytime they use the script. This can be done by adding a prompt to enter the username and a check if this is correct but i have no experience with powershell how to give a prompt to fill in a variable.

Can someone show me how this is done? I prefer to use it in combination with the function Show-Menu so i can add more functionality to the script in a later stage .
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Lennart GiaccottoAdministrator

Author

Commented:
Thank you for your awnser oBdA. If I place this in a file and run it nothing happens. no error or anything else/

**edit**

I see this is a function which in turn i have to call before it does anything(?)
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Lennart GiaccottoAdministrator

Author

Commented:
Thanks! This works just fine. I still can't get it working in the Show-Menu option but the script itself works great!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions