0
votes

Im trying to write a powershell query to return the following table:

NAME    STATUS  RESOURCE GROUP  VMSIZE  SIZEREASON (TAG)    LOCATION    PUBLIC DNS NAME

I can use Get-AzureRmVM | Select-Object Name, ResourceGroupName, Location but when I try to add on VmSize, the column is there but without values.

If I run just Get-AzureRmVM then I get the VmSize, so I don't understand why I can't select it.

I also need to work out how to add in Status, SIZEREASON (TAG),PUBLIC DNS NAME

Any guidence is most appreciated.

Its also worth noting, that my table also needs to contain both Resource Managed VM's and Classic VM's (So all VM's)

UPDATE

My Powershell query is currently:

Get-AzureRmVm `
  | Select-Object ResourceGroupName `
                , Name `
                , Location `
                , @{Name="VmSize"; Expression={$_.ToPSVirtualMachine().HardwareProfile.VmSize}} `
                , @{Name="SizeReason(Tag)"; Expression={$_.ToPSVirtualMachine().Tags.Values}} `
                , FullyQualifiedDomainName `
   | Format-Table

The outstanding problems are:

  1. FullyQualifiedDomainName does not work
  2. I am also missing the status (Eg: Running, Stopped (Deallocated) etc..)
1
Check the output of Get-AzureRmVM | Get-Membergvee
I had also done that but I can not see a property called VmSize, even though just running 'Get-AzureRmVM' gives me VmSizeJeffrey

1 Answers

1
votes

This was trickier than I expected....

Get-AzureRmVm | Select-Object @{Name="VmSize"; Expression={$_.ToPSVirtualMachine().HardwareProfile.VmSize}}