Changing the Administrator password on EC2 instance using Powershell

This topic contains 1 reply, has 2 voices, and was last updated by  postanote 3 weeks, 6 days ago.

  • Author
    Posts
  • #82679

    jason smith
    Participant

    Hello Good folks,

    I spun up an EC2 windows instance. Using the following powershell script, I tried to change the password of the Adminstrator. I am using ADSI (active directory service interface) in the command below.

    This doesn't work. Any suggestions are greatly appreciated. Thanks much

    "Powershell.exe ([adsi]\\\"WinNT://$env:computername/Administrator\\\").SetPassword('",{ "Ref": "LocalAdminPassword"},"')"

  • #82696

    postanote
    Participant

    I love me some PoSH, but sometimes old school is just more straight forward.
    Why not just use Net User.

    net user administrator

    Or if you really want to stick with ADSI, then, try this...

    ([adsi]"WinNT://$env:COMPUTERNAME/$env:USERNAME").SetPassword("Whatever password you choose")

    You can wrap that in a PoSH script even, if you 'd like.

You must be logged in to reply to this topic.