我已经通过 成功收集了 AMI ID Get-EC2ImageByName
,但我正在尝试确定一种方法来提取最新的“not-rc”AMI。
我目前运行:
Get-EC2ImageByName -Names *amzn-ami-pv*x86_64*ebs* - | Select-Object -ExpandProperty "ImageId" -First 1
它给了我:
ami-978639e4
当我运行时:
Get-EC2ImageByName -Names *amzn-ami-pv*x86_64*ebs*
前 2 个条目是:
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1}
CreationDate : 2016-02-27T22:30:03.000Z
Description : Amazon Linux AMI 2016.03.rc-0 x86_64 PV EBS
Hypervisor : xen
ImageId : ami-978639e4
ImageLocation : amazon/amzn-ami-pv-2016.03.rc-0.x86_64-ebs
ImageOwnerAlias : amazon
ImageType : machine
KernelId : aki-52a34525
Name : amzn-ami-pv-2016.03.rc-0.x86_64-ebs
OwnerId : 137112412989
Platform :
ProductCodes : {}
Public : True
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SriovNetSupport :
State : available
StateReason :
Tags : {}
VirtualizationType : paravirtual
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1}
CreationDate : 2016-02-10T22:22:22.000Z
Description : Amazon Linux AMI 2015.09.2 x86_64 PV EBS
Hypervisor : xen
ImageId : ami-a93484da
ImageLocation : amazon/amzn-ami-pv-2015.09.2.x86_64-ebs
ImageOwnerAlias : amazon
ImageType : machine
KernelId : aki-52a34525
Name : amzn-ami-pv-2015.09.2.x86_64-ebs
OwnerId : 137112412989
Platform :
ProductCodes : {}
Public : True
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SriovNetSupport :
State : available
StateReason :
Tags : {}
VirtualizationType : paravirtual
我试图忽略“rc”条目,并选择名称中没有“rc”的第一个 AMI ID,或者只是第一个“not rc”AMI ID。在这个例子中,我想要的 AMI-ID 是:
ami-a93484da
有谁知道在不使用“ -Skip 1
”的情况下实现这一目标的方法?(我避免使用“ -Skip 1
”,因为我试图使脚本可重复,例如,如果有 2 个或更多“rc”版本。
谢谢你的帮助!