Virtual Machine Details

Anonymous
2020-03-06T12:07:56.293+00:00

How can I list the VM's details like OS version (2008 2016 etc) SKU (A1 B2 ) processor type and number of cores (VCPU) for all the VM's in my subscription.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,365 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. jakaruna-MSFT 596 Reputation points Microsoft Employee
    2020-03-09T12:01:33.687+00:00

    You can list the VM name and sku by using azure resource graph.

    With the sku details you can figure out the number of core used.

    Sample command:

    az graph query -q "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project name, location, type, properties.hardwareProfile.vmSize| order by name desc" --first <number of entries needed>

    For getting details about the OS version, you need to login to the VM and execute commands to get the information.


  2. Anonymous
    2020-03-11T16:20:18.313+00:00

    For anyone interested here how I was able to get the details.

    function Get-AzureRMVMInfo {
    <#
    .SYNOPSIS
    Gets basic information on one or more Azure VMs.
    .DESCRIPTION
    Get CPU, memory and IP configuration with a simple cmdlet.
    Pipeline input accepts multiple vm objects.
    .EXAMPLE
    Get-AzureRMVMInfo -VMName "VM1" -ResourceGroupName "RG1"
    This command gets the CPU, memory and internal IP for VM "VM1".
    .EXAMPLE
    Get-AzureRMVM | Get-AzureRMVMInfo
    This command gets all VMs in the current subscription, then uses the output to surface all basic configuration on these VMs.
    .EXAMPLE
    Get-AzureRMVM | Get-AzureRMVMInfo | Sort "Internal IP"
    This command gets all VMs in the current subscription, then uses the output to surface all basic configuration on these VMs, sorted by Internal IP.
    [cmdletbinding(DefaultParameterSetName = 'Name')]
    Param(
    [Parameter(Mandatory = $true, ParameterSetName = 'Name')]
    [string]$VMName,
    [Parameter(Mandatory = $true, ParameterSetName = 'Name')]
    [string]$ResourceGroupName,
    [Parameter(ValueFromPipeline, Mandatory = $true, ParameterSetName = 'Object')]
    $VM
    )
    process {
    if ($pscmdlet.ParameterSetName -eq "Name") {
    $vm = Get-AzureRMVM -Name $VMName -ResourceGroupName $ResourceGroupName
    }

        $sizeinfo = get-azurermvmsize -VMName $vm.name -ResourceGroupName $vm.ResourceGroupName | Where-Object {$_.Name -eq $vm.hardwareprofile.vmsize}
        $privateip = (Get-AzureRmNetworkInterface | where-Object {$_.Id -eq $vm.NetworkProfile.NetworkInterfaces[0].Id}).IpConfigurations[0].PrivateIPAddress
        $vminfo = [pscustomobject][ordered] @{
            Name          = $vm.Name
            CPU           = $sizeinfo.numberofcores
            &#34;Memory (GB)&#34; = $sizeinfo.MemoryInMB * 1mb / 1gb
            &#34;Internal IP&#34; = $privateip      
        }
        $vminfo
    }
    

    }

    0 comments No comments