Reset Users AD Password with Powershell
This powershell script goes and resets a users account in Active Directory.
Requirements:
- Must have permissions to reset passwords in AD.
- If this is run from any other powershell then you need to import the Active Directory Module. Remove the # tag from lines 3,4 and 5 to do this.
- The account info needs to be accurate or it wont be able to reset the password.
- Once the reset has taken place it will prompt the user to change there password at first login.
##Untag the first 3 lines if you are not running this from a domain controller. you will then need to import the Active Directory Module. #$Session = New-PSsession -Computername $dc -Credential $user #Invoke-Command -Command {Import-Module ActiveDirectory} -Session $Session #Import-PSSession -Session $Session -Module ActiveDirectory -Prefix RM -AllowClobber # Show input box popup and return the value entered by the user. function Read-InputBoxDialog([string]$Message, [string]$WindowTitle, [string]$DefaultText) { Add-Type -AssemblyName Microsoft.VisualBasic return [Microsoft.VisualBasic.Interaction]::InputBox($Message, $WindowTitle, $DefaultText) } $Username = Read-InputBoxDialog -Message "Please enter the UserName of the account you want to reset" -WindowTitle "User Name" $ChangePWD = Read-InputBoxDialog -Message "Please enter the Users Password'" -WindowTitle "Password" $ChangePWD = convertto-securestring $ChangePWD -AsPlainText -Force Set-ADAccountPassword $Username -NewPassword $ChangePWD -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True |