我试图列出所有AWS卷,并通过powershell获取它所连接的实例。我正在运行下面显示的具有帐户根特权的powershell程序。
使用这些文件:
a. https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/TVolume.html
b. https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/TVolumeAttachment.html
我用的是密码:
$volno=0
foreach ($i in Get-EC2Volume) {
++$volno
write-host $i.VolumeId $i.Name $i.Size $i.VolumeType
write-host $i.Atachments.Count
foreach ($j in $i.Atachments) {
$j.InstanceId
}
}我得到了以下结果:
vol-83d1e111 10 gp2
0
vol-2248a222 8 gp2
0
vol-4b48a333 30 gp2
0
vol-345fbf44 50 gp2
0
vol-b4876b55 8 gp2
0
....问题
System.Collections.Generic.List类型
andReference b.显示Amazon.EC2.Model.VolumeAttachment有一个InstanceId成员发布于 2018-03-14 04:37:59
对不起,有一个错误我没有注意到:
写主机$i.Atachments.Count
应该是
写主机$i.Attachments.Count
和
foreach ($j in $i.Atachments) {
应该是
foreach ($j in $i.Attachments) {
https://stackoverflow.com/questions/49247166
复制相似问题