Link to home
Start Free TrialLog in
Avatar of Lennart Giaccotto
Lennart Giaccotto

asked on

Interactive Powershell script to reset password age in AD

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 .
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

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
Avatar of Lennart Giaccotto
Lennart Giaccotto

ASKER

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(?)
SOLUTION
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
Thanks! This works just fine. I still can't get it working in the Show-Menu option but the script itself works great!