Share via


Finding out all the VMs in a Resource Group using Powershell

Question

Monday, February 19, 2018 12:36 AM

I am trying to run the below command in powershell to find out all the VMs in a particular RG

Get-AzureRmVM -ResourceGroupName "MyRG1"

It displays the VMNames along with the RG Name , Region,Spec of the VM,OS Type and NIC Provisioning State

But i would like to only display the columns for VM Names and Spec of the VM and OS Type.

But when i run the command below :

Get-AzureRmVM -ResourceGroupName "MyRG1" | ft Name,OSType,VmSize, it shows the below out put 

If i run the command Get-AzureRmVM -ResourceGroupName "MyRG1" | ft Name,ResourceGroupName,VmSize it shows the below result

Why VmSize or OSType columns are coming blank?

Pallab Chakraborty

All replies (1)

Monday, February 19, 2018 1:14 AM âś…Answered

Try

Get-AzureRmVM -ResourceGroupName ResourceGroupName | ft Name, ResourceGroupName, {$_.HardwareProfile.VmSize}, {$_.StorageProfile.OsDisk.OsType}