A simple script to refresh an expired Active Directory password.
Report Bug
·
Request Feature
Table of Contents
A very useful script to refresh an expired password for a user account in Active Driectory. This is done by setting the AD attribute pwdlastset
to todays date. To do this you set the pwdlastset
field to 0
, this means that the password has never been set. Once that is applied you go back and set the attribute to -1
, this sets the password to the current date and time. The password will then no longer flag as expired and the user can continue to use the current password.
To get a local copy up and running follow these simple example steps.
You will need have the ActiveDirectory PowerShell module installed, if you are running Windows 10 version 1809 and later run the following command.
- powershell
Add-WindowsCapability -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 -Online
If you are running Windows Server 2008 to 2022 run the following command.
- powershell
Install-WindowsFeature -Name "RSAT-AD-PowerShell" -IncludeAllSubFeature
If you are running a Windows 10 version 1809 prior to 1809 you can install the RSAT tools from here
- Browse to the folder you store your scripts
e.g. cd C:\Script
- Clone the repo
Invoke-WebRequest -Uri https://raw.githubusercontent.com/ELLISB1000/Refresh-ADPassword/main/Refresh-ADPassword.ps1 -OutFile .\Refresh-ADPassword.ps1
Run the script against a single user account.
.\Refresh-ADPassword.ps1 -username "Test.User"
Run the script against multiple user accounts from the output of Get-ADuser.
$ADUsers = Get-ADUser -filter {enabled -eq $true} #You can customize the filter applied
foreach ($ADUser in $ADUsers) {.\Refresh-ADPassword.ps1 -username $ADUser.samaccountname}
- Ability to run script against users in a csv file.
- Add logging
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.