![](/img/trans.png)
[英]How can I know the Name of the “IAM role” attached to EC2 using PowerShell from EC2 Instance itself?
[英]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.