How do I create a new user in Windows with a user-data script on AWS?

3.9k Views Asked by At

I never use Windows; so bear with me here. I'm trying to make this simple; all I want to do is create a new user, with a defined password, that I can use to RDP to my instance on AWS.

I've put the following into a user-data script (And tried about 40 other different ways as well) to no avail.

<powershell>

cmd.exe /c net user /add developer myP@ssworD1
cmd.exe /c net localgroup administrators developer /add
cmd.exe /c NET LOCALGROUP "Remote Desktop Users" developer /ADD

</powershell>

My end-goal here is that I want to use provision an AMI with Packer, which I believe is working - but I can never login with AWS' means of "Get Windows Password" as it never resolves.

Any solution to get me past this step would be extremely helpful.

2

There are 2 best solutions below

0
On

Solution was to wrap in <script></script> instead while dropping the cmd.exe; and looks as if adding to the RDP group was not necessary.

<script>

net user /add developer myP@ssworD1
net localgroup administrators developer /add

</script>
1
On
net user /add developer myP@ssworD1
net localgroup administrators developer /add
net localgroup "Remote Desktop Users" developer /add