I am trying to use the following script, but was not successful:
$Ami=Get-EC2ImageByName WINDOWS_2012_BASE
New-EC2Instance -ImageId $Ami[0].ImageId -MinCount 1 -MaxCount 1 -KeyName uckey -InstanceType `
t1.micro -SubnetId subnet-56738b33 -AssociatePublicIp $true
Error:
New-EC2Instance : Object reference not set to an instance of an object.
At line:1 char:1
+ New-EC2Instance -ImageId $Ami[0].ImageId -MinCount 1 -MaxCount 1 -KeyName uckey ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Amazon.PowerShe...2InstanceCmdlet:NewEC2InstanceCmdlet)
[New-EC2Instance], InvalidOperationException
+ FullyQualifiedErrorId : System.NullReferenceException,Amazon.PowerShell.Cmdlets.EC2.NewEC2InstanceC
mdlet
The problem is the parameter -AssociatePublicIpwithout it, the script is running.
Thanks for reading
Evren source
share