Shows on how to reset an AD user account's password and force the user to change the password next time the user log in.
Basic Script:
Set-ADAccountPassword -Identity $username -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$password" -force) -Confirm:$false
Set-ADUser -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Identity $username -Confirm:$false
Script to take the input values and change the password:
$username=Read-Host -Prompt "Enter User Name for Password reset"
$password=Read-Host -Prompt "Enter a Password"
Set-ADAccountPassword -Identity $username -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$password" -force) -Confirm:$false
Set-ADUser -PasswordNeverExpires $true -ChangePasswordAtLogon $false -Identity $username -Confirm:$false
Write-host $username 'Password has been reset and set to change at Next Logon' -F green
Get-aduser -identity $username -properties department, mail, title, description, PasswordNeverExpires, PasswordLastSet