[英]Only list name of EC2 using Powershell
I set an a variable $ec2-instance = GetEC2Instance
and this returns something like... 我设置了一个变量
$ec2-instance = GetEC2Instance
,这返回类似...
GroupNames : {} Groups : {} Instances : {somekey} OwnerId : 11111111 RequesterId : ReservationId : r-111111111
What I'm trying to do is list just the name of the EC2 instance. 我想做的只是列出EC2实例的名称。 I know, "name" is a tag but not sure how to capture in PowerShell.
我知道“名称”是一个标记,但不确定如何在PowerShell中捕获。
Get-EC2Instance
returns a list of Instances, you can iterate over that list and grab the value of the Name tag like this: Get-EC2Instance
返回实例列表,您可以遍历该列表并按如下方式获取Name标记的值:
ForEach($i in (Get-EC2Instance).Instances) {
($i.Tags | ? { $_.Key -eq "Name"} | select -expand Value)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.