Changing the Administrator password on EC2 instance using Powershell

Welcome Forums General PowerShell Q&A Changing the Administrator password on EC2 instance using Powershell

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #82679

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 227
    Helping Hand
    Rank: 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.

The topic ‘Changing the Administrator password on EC2 instance using Powershell’ is closed to new replies.