locked
VM Size of Machines not getting displayed along with VMNames while trying to run an Azure Powershell Command RRS feed

  • Question

  • I want to see all the VM names in Azure belonging to a particular Resource Group. So i ran the command :

    Get-AzureRmVM -ResourceGroupName "myresourcegroup"

    This displays all the VM names along with the Resource Group Name, Location, VM Size , OS Type  and NIC Provisioning State.But i want to just display the Name of the VM along with the VM Type. So i run the below command :

    Get-AzureRmVM -ResourceGroupName "myresourcegroup" | ft Name,ResourceGroupName,VmSize  -AutoSize , but the output doesn't display anything on the VMSize column. Only Name and ResourceGroupName fields are populated.

    Can anyone tell why the VMSize field is not getting populated with the above command, i also tried | ft Name,VMSize -Autosize, still no go

     


    Pallab Chakraborty

    Sunday, February 18, 2018 11:44 PM

Answers

  • What if you put  instead of hardwareprofile.vmsize this:

    @{Label="VmSize";Expression={$_.HardwareProfile.VmSize}}


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Monday, February 19, 2018 12:32 AM
  • Hi,

    According to your description, I recommend using Get-Member cmdlet for viewing the structure of an object, for example: Get-AzureRmVM -ResourceGroupName 'Name' | Get-Member. After that, you will be able to get any properties you want. The following article for your reference:
    Viewing Object Structure (Get-Member)
    https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/viewing-object-structure--get-member-?view=powershell-6

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 19, 2018 12:15 PM
  • Hi,

    I am checking how the issue is going, if you still have any questions, please feel free to contact us.

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Appreciate for your feedback.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Palchak Friday, February 23, 2018 1:18 PM
    Friday, February 23, 2018 3:04 AM

All replies

  • Hi Palchack

    The size of the VM, it’s actually stored under the HardwareProfile property

    You should go with hardwareprofile.vmsize

    Regards

    Simon


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Monday, February 19, 2018 12:14 AM
  • Simon, i am attaching the screenshot for your reference.

    It still doesn't show the VM Size after specifying what you said.

    Please take a look below


    Pallab Chakraborty

    Monday, February 19, 2018 12:25 AM
  • What if you put  instead of hardwareprofile.vmsize this:

    @{Label="VmSize";Expression={$_.HardwareProfile.VmSize}}


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Monday, February 19, 2018 12:32 AM
  • Thanks for your suggestion, that worked. Please see below

    So could you please explain to me why i had to do this particularly to display VmSize, i didn't have to do anything special to display the ResourceGroupName, but just for displaying 3 columns selectively, why special treatment was done for displaying VmSize?


    Pallab Chakraborty

    Monday, February 19, 2018 12:42 AM
  • Also, for displaying OsType what shall i use ? HardwareProfile is not working for displaying OsType

    Pallab Chakraborty

    Monday, February 19, 2018 12:48 AM
  • Hi,

    According to your description, I recommend using Get-Member cmdlet for viewing the structure of an object, for example: Get-AzureRmVM -ResourceGroupName 'Name' | Get-Member. After that, you will be able to get any properties you want. The following article for your reference:
    Viewing Object Structure (Get-Member)
    https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/viewing-object-structure--get-member-?view=powershell-6

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 19, 2018 12:15 PM
  • Hi,

    I'm checking how the issue is going, was your issue resolved?

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 21, 2018 4:58 AM
  • Hi,

    I am checking how the issue is going, if you still have any questions, please feel free to contact us.

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Appreciate for your feedback.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Palchak Friday, February 23, 2018 1:18 PM
    Friday, February 23, 2018 3:04 AM