Changing the Administrator password on EC2 instance using Powershell

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”},“')”

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.