简体   繁体   English

Azure Powershell-获取具有大小的VM列表

[英]Azure powershell - Get list of VMs with size

Trying to get a basic powershell script to retrieve the VM name and VM size. 尝试获取基本的Powershell脚本以检索VM名称和VM大小。

I can run the following command: 我可以运行以下命令:

Get-AzureRMVM

This shows a list of VMs with "name" and "VMSize" columns, among others. 这显示了带有“名称”和“ VMSize”列的VM列表。 I'm just trying to display those two columns, so I have this: 我只是想显示这两列,所以我有:

[array]$VMs = Get-AzureRMVm 

foreach ($VM in $VMs)
 {
Write-Output "VM: $($VM.Name)"
Write-Output "VM Size: $($VM.VmSize)"
 }

For some reason while the VM name is showing up, the size is not. 由于某种原因,在显示VM名称时,大小没有显示。 Any idea what i'm doing wrong? 知道我在做什么错吗?

VmSize is pulled from HardwareProfile. VmSize从HardwareProfile中拉出。 Try using $VM.HardwareProfile.VMSize 尝试使用$VM.HardwareProfile.VMSize

Reference. 参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM