AntiMalware Status

Reset Password for user in Active Directory

Quick Help Desk script tool in PowerShell to reset user password :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Clear-Host
Import-Module ActiveDirectory

$newpwd = Read-Host "[ Enter the new password ]" -AsSecureString
$User = Read-Host "[ Enter UserName ]"

Write-Host
Write-Host .. Password Reset for $user -ForegroundColor white -BackgroundColor Red
Write-Host

Set-ADAccountPassword $User -NewPassword $newpwd –Reset

Write-Host "[ Change Report ]" -ForegroundColor -white -BackgroundColor green
Get-ADuser -identity $User -Properties * | Select-Object SamAccountName,PasswordLastSet,Enabled | Format-List
  • Enter new password for the user
  • Enter username for user you are trying to reset password
  • Shows result for the user that password has been reset

Force the user to change password on first login you need to run this line :

1
Set-ADUser -identity $User -ChangePasswordAtLogon:$True

Leave a Reply