locked
Reset the password in Active Directory. RRS feed

  • Question

  • Hi,

    I am facing some issue with this script .. Could you please suggest the changes I need to make?

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

    # We'll enter a new password

    Set-ADAccountPassword jfrost -NewPassword $new

    Set-ADAccountPassword jfrost -NewPassword

    (ConvertTo-SecureString -AsPlainText -String

    "P@ssw0rd1z3" -force)

    Set-ADUser jfrost -ChangePasswordAtLogon $True

    Wednesday, October 12, 2016 2:06 PM

Answers

  • First:  You would get a better response if you would post readable code and not badly broken code.

    Read-Host returns a secure string when the -AsSecureString argument is passed.

    You must use the "-Reset" argument if you are not supplying the old password.

    $newpwd = Read-Host "Enter the new password" -AsSecureString
    Set-ADAccountPassword jfrost -NewPassword $newpwd -Reset
    Set-ADUser jfrost -ChangePasswordAtLogon
    

    The new password must meet all complexity requirements.

    ALWAYS!  Read the help for the CmdLet completetly: https://technet.microsoft.com/en-us/library/ee617261.aspx


    \_(ツ)_/

    Wednesday, October 12, 2016 4:04 PM

All replies

  • As you can see, random copy and paste guesswork isn't going to produce something that works.

    What exactly are you trying to do?


    -- Bill Stewart [Bill_Stewart]

    Wednesday, October 12, 2016 3:02 PM
  • And what is the issue you refer to? Do you get an error message? If so, what is the message?

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, October 12, 2016 3:15 PM
  • And why are you attempting to first set the password to the securestring $new and then to a different, but not at all secure string 'P@ssw0rd1z3'?

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join('6D73646E5F6B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})


    • Edited by Just Karl Wednesday, October 12, 2016 3:38 PM
    Wednesday, October 12, 2016 3:38 PM
  • First:  You would get a better response if you would post readable code and not badly broken code.

    Read-Host returns a secure string when the -AsSecureString argument is passed.

    You must use the "-Reset" argument if you are not supplying the old password.

    $newpwd = Read-Host "Enter the new password" -AsSecureString
    Set-ADAccountPassword jfrost -NewPassword $newpwd -Reset
    Set-ADUser jfrost -ChangePasswordAtLogon
    

    The new password must meet all complexity requirements.

    ALWAYS!  Read the help for the CmdLet completetly: https://technet.microsoft.com/en-us/library/ee617261.aspx


    \_(ツ)_/

    Wednesday, October 12, 2016 4:04 PM