Home / AWS

AWSTroubleshootingIntermediate

EC2 Windows instance says 'Password not available yet' and user data never ran: EC2Launch v2 checks and fixes

A new Windows instance has no retrievable password or skipped its user data. Read the EC2Launch v2 log, fix custom AMIs that were never reset, and make scripts run again.

Deepak Bhardwaj7 min read

Applies toAmazon EC2 Windows Server 2016-2025 instances with EC2Launch v2; AWS CLI v2. Older AMIs with EC2Launch v1 or EC2Config use different paths.

You launched a Windows instance, waited, and the console still says "Password not available yet". Or the password works but the bootstrap script in user data never ran, so the instance has no agent, no domain join and no app. Both problems usually have the same cause: the EC2Launch v2 agent did not run its first-boot tasks, or ran them with settings you did not expect.

Quick triage

Symptom Likely cause Fix
"Password not available" after 15+ minutes on an AWS AMI Instance launched without a key pair, or still booting Check KeyName, console screenshot
Same, on a custom AMI AMI captured without EC2Launch reset/Sysprep, so first-boot tasks are marked done Rebuild AMI with EC2Launch.exe reset + sysprep
get-password-data returns an empty string Password generation disabled in agent-config.yml (doNothing/static) Change the setAdminAccount task
Can't decrypt with your key Wrong key file, or ED25519 key (not supported for Windows passwords) Use the RSA key the instance launched with
User data ran on first boot only Default frequency is once <persist>true</persist> or frequency: always
User data never ran at all Wrong tags/format, script error, or AMI not reset Read agent.log

Check 1: did the instance launch with a key pair?

Windows password retrieval needs the key pair that was specified at launch. AWS encrypts the generated password with that key.

aws ec2 describe-instances --instance-ids i-0abc123def4567890 \
  --query "Reservations[].Instances[].[KeyName,ImageId,LaunchTime,PlatformDetails]" \
  --output table

If KeyName is empty, you cannot get the password through the console. Reset it through Systems Manager (Check 6) or launch a new instance with a key.

Retrieve and decrypt the password from the CLI:

aws ec2 get-password-data --instance-id i-0abc123def4567890 \
  --priv-launch-key ~/.ssh/win-prod.pem \
  --query PasswordData --output text

An empty PasswordData after more than 15 minutes means the agent never posted a password. Keep going.

Tip

Windows password decryption requires an RSA key pair. ED25519 key pairs are not supported for Windows instances. If your team standardised on ED25519, keep one RSA key for Windows launches.

Check 2: is Windows actually up?

Before blaming EC2Launch, confirm that the OS finished booting:

aws ec2 describe-instance-status --instance-ids i-0abc123def4567890 \
  --query "InstanceStatuses[].[SystemStatus.Status,InstanceStatus.Status]" --output text

aws ec2 get-console-output --instance-id i-0abc123def4567890 --latest --output text

aws ec2 get-console-screenshot --instance-id i-0abc123def4567890 \
  --query ImageData --output text | base64 -d > screen.jpg

A screenshot stuck on "Getting Windows ready" or an update screen means you need to wait or fix the boot, not the password. Console output from EC2Launch v2 includes lines about the password and the state of user data once the agent reaches that point.

Check 3: read the EC2Launch v2 log

If you can get on the instance at all (Session Manager, a known local account, or the volume attached to a helper instance), the agent log is the source of truth:

Get-Content "$env:ProgramData\Amazon\EC2Launch\log\agent.log" -Tail 200
Select-String -Path "$env:ProgramData\Amazon\EC2Launch\log\agent.log" -Pattern "error|fail|userdata|setAdminAccount"

Then check what configuration the agent is running with:

& "$env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" get-agent-config --format yaml
& "$env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" status

EC2Launch.exe is not on the PATH, so always call it by full path.

Check 4: custom AMI captured without a reset

This is the most common cause on golden images. EC2Launch v2 records which first-boot tasks it has finished. If you build an image from a running instance without resetting the agent, every instance launched from that AMI believes first boot already happened. It skips password generation, keeps the old computer name, and may skip run-once user data.

Fix the build, not each instance. On the build instance, as the last step before capture, run:

& "$env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" reset --clean
& "$env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" sysprep --shutdown

You can also choose Shutdown with Sysprep in the EC2Launch settings dialog. Create the image once the instance has stopped.

Warning

Sysprep generalises the instance. It removes the machine SID and domain membership and may reset local settings. Run it only on a build instance, never on a production server you intend to keep.

If an EC2 Image Builder pipeline produces the AMI, check that the pipeline's Windows distribution step runs Sysprep. Teams that customise the build often turn this off by accident.

Check 5: password generation is configured off

The setAdminAccount task in C:\ProgramData\Amazon\EC2Launch\config\agent-config.yml controls the Administrator password. A hardened image might contain:

- task: setAdminAccount
  inputs:
    password:
      type: doNothing

With doNothing, no password is generated, so get-password-data stays empty. static sets a fixed password from the config, which is risky. For password retrieval to work, type must be random. Names and allowed values vary by EC2Launch v2 version, so validate after editing:

& "$env:ProgramFiles\Amazon\EC2Launch\EC2Launch.exe" validate

If your security baseline deliberately disables local admin passwords, document the access path you use instead, usually Session Manager or Fleet Manager RDP.

Check 6: get in without the password

If the SSM Agent is registered (it is on AWS Windows AMIs, if the instance profile and network allow it), you do not need the generated password:

aws ssm start-session --target i-0abc123def4567890

From the session, set a known password, or create a break-glass account that your vault rotates:

net user Administrator 'Use-A-Vaulted-Value-Here-1!'

The AWSSupport-ResetAccess Automation runbook can also reset the local Administrator password. It stores the new value encrypted in Parameter Store. Check the runbook's prerequisites in the SSM console before you rely on it.

User data that never ran, or ran only once

Format

EC2Launch v2 accepts two formats. Script-tag format:

<powershell>
Start-Transcript -Path C:\Windows\Temp\bootstrap.log -Append
Install-WindowsFeature Web-Server
Stop-Transcript
</powershell>
<persist>true</persist>

YAML format:

version: 1.1
tasks:
  - task: executeScript
    inputs:
      - frequency: always
        type: powershell
        runAs: localSystem
        content: |-
          Start-Transcript -Path C:\Windows\Temp\bootstrap.log -Append
          Install-WindowsFeature Web-Server
          Stop-Transcript

Common mistakes: a missing closing </powershell> tag, YAML indented with tabs, Base64-encoding the data twice in a launch template, and expecting the script to run on every boot without persist or frequency: always.

Check what the instance actually received:

aws ec2 describe-instance-attribute --instance-id i-0abc123def4567890 \
  --attribute userData --query UserData.Value --output text | base64 -d

Reboots inside user data

If the script restarts the machine, EC2Launch v2 keeps the user data marked as pending and runs it again on the next boot. Scripts that reboot must be idempotent. Write a marker file and check for it, or the script loops.

Make the script tell you what happened

Add Start-Transcript as the first line, as in the examples above. The agent log tells you whether the script started. Your transcript tells you where it failed. Ship it to CloudWatch Logs with the CloudWatch agent if you launch at scale.

Prevent it next time

  • End every Windows AMI build with EC2Launch.exe reset and Sysprep, and test the AMI by launching it and calling get-password-data in the pipeline.
  • Keep one RSA key pair for Windows launches, or standardise on Session Manager and stop depending on the generated password.
  • Put Start-Transcript and a marker-file check in every user data script.
  • Store your agent-config.yml in source control and run EC2Launch.exe validate during the image build.