none
Powershell Set-ADuser -ChangePasswordAtLogon $true not working RRS feed

  • Question

  • Hello,

    Thank in advance for any input.  I am using powershell 3.0 on windows 7 machine and windows server 2008 R2.  I am tring to reset a users password and mark it to change their password at next log in, but it does not seem to work for me use my varibles..

    $GETnewPwd = (Read-Host "New Student Password is");
    
    Set-AdaccountPassword -Identity $CHANGEwho -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $GETnewPwd -Force) |
                        Set-ADuser -ChangePasswordAtLogon $true -Enabled $true -PasswordNeverExpires $false;
                            Write-Host "$CHANGEwho Password was updated" -ForegroundColor Green

    Tuesday, October 21, 2014 5:41 PM

Answers

  • Hi,

    Did you get any error? Or this script just can't work without error.

    To reset the password for user and force user to change their password at the next logon, please also try the script below:

    $newpwd = Read-Host "Enter the new password" -AsSecureString

    Set-ADAccountPassword -Identity $CHANGEwho -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True

    If there is anything else regarding this script, please feel free to post back.

    Best Regards,

    Anna Wang

    • Marked as answer by bigdog704 Wednesday, October 22, 2014 1:16 PM
    Wednesday, October 22, 2014 7:42 AM
    Moderator

All replies

  • Hi,

    Did you get any error? Or this script just can't work without error.

    To reset the password for user and force user to change their password at the next logon, please also try the script below:

    $newpwd = Read-Host "Enter the new password" -AsSecureString

    Set-ADAccountPassword -Identity $CHANGEwho -NewPassword $newpwd -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True

    If there is anything else regarding this script, please feel free to post back.

    Best Regards,

    Anna Wang

    • Marked as answer by bigdog704 Wednesday, October 22, 2014 1:16 PM
    Wednesday, October 22, 2014 7:42 AM
    Moderator
  • Refer this as well

    https://gallery.technet.microsoft.com/Reset-AD-User-Password-and-bcd31566


    Regards Chen V [MCTS SharePoint 2010]

    Wednesday, October 22, 2014 9:15 AM