簡體   English   中英

僅使用Powershell列出EC2的名稱

[英]Only list name of EC2 using Powershell

我設置了一個變量$ec2-instance = GetEC2Instance ,這返回類似...

GroupNames : {} Groups : {} Instances : {somekey} OwnerId : 11111111 RequesterId : ReservationId : r-111111111

我想做的只是列出EC2實例的名稱。 我知道“名稱”是一個標記,但不確定如何在PowerShell中捕獲。

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM