Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Get-EC2PasswordData return "The parameter is incorrect."?

I'm using powershell to call Get-EC2PasswordData like so:

$instances = (Get-EC2Instance -Filter @($envFilter, $stateFilter)).Instances

$instances | Foreach-object {
    $instID = $_.InstanceId
    Write-Host Getting password to $instID...
    $password = Get-EC2PasswordData -InstanceId $instID -PemFile "c:\my.pem" -Decrypt
    Write-Host Username/Password for $_.PrivateIpAddress is Administrator/$password

}

And I get the following:

Getting password to i-3e961280 ...
Get-EC2PasswordData : Value cannot be null.
Parameter name: s
At C:\temp\CIS-aws-volumes\copyToMachine.ps1:12 char:17
+     $password = Get-EC2PasswordData -InstanceId $instID -PemFile "c:\docs\ssh\ci ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Amazon.PowerShe...swordDataCmdlet:GetEC2PasswordDataCmdlet) [Get-EC2
   PasswordData], ArgumentNullException
    + FullyQualifiedErrorId : InvalidOperationException,Amazon.PowerShell.Cmdlets.EC2.GetEC2PasswordDataCmdlet

Username/Password for 10.185.30.124 is Administrator/

What does "Get-EC2PasswordData : Value cannot be null." mean? I'm not passing in any null values.

like image 687
Ryan Shillington Avatar asked Nov 16 '15 23:11

Ryan Shillington


1 Answers

Turns out the answer is because the password isn't available yet. You just need to wait for a while for the machine to come up. You'll find that you also can't get the Windows admin password in the console yet either (although ti gives a much more intuitive message).

If you've waited a long time, it's probably because your Ec2ConfigService isn't configured on the machine to reset the password. You might need to change "C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml". In there you'll find a piece near the top like this:

<Plugin>
  <Name>Ec2SetPassword</Name>
  <State>Disabled</State>
</Plugin>

Change the "Disabled" to "Enabled":

<Plugin>
  <Name>Ec2SetPassword</Name>
  <State>Enabled</State>
</Plugin>

I wanted to post this to the internet somewhere so the next guy who Googles "Get-EC2PasswordData : Value cannot be null" might find something useful.

like image 200
Ryan Shillington Avatar answered Nov 19 '22 20:11

Ryan Shillington