Xrk
Xrk

Reputation: 5

Is there a way to find out what type of disk is being used in a virtual machine in Azure using powershell?

I need to find out what type of disk is using a VM in Azure, specifically I need to know if the disk is SSD or HDD, using powershell.

I know I can find that info in the Azure portal, but I need to do so using a powershell script.

With the StorageProfile property of a Virtual machine object, I can find some info:

    PS C:\WINDOWS\system32> $azureVM.StorageProfile.OsDisk

    OsType                  : Windows
    EncryptionSettings      :
    Name                    : ServerX1Disk0
    Vhd                     :
    Image                   :
    Caching                 : ReadWrite
    WriteAcceleratorEnabled :
    DiffDiskSettings        :
    CreateOption            : Attach
    DiskSizeGB              : 256
    ManagedDisk             : Microsoft.Azure.Management.Compute.Models.ManagedDiskParameters

But I cannot find the info about if this disk is SSD or HDD. Any help will be appreciated.

Upvotes: 0

Views: 9373

Answers (2)

AdminOfThings
AdminOfThings

Reputation: 25001

The following property is what you are looking for:

$azureVM.StorageProfile.OsDisk.ManagedDisk.StorageAccountType

If you have data disks, they are accessed on a different property (DataDisks). Keep in mind that DataDisks property is a collection so you may need to use indexing or loop to access the disk(s) you want:

$azureVM.StorageProfile.DataDisks[index].ManagedDisk.StorageAccountType

Possible values for StorageAccountType include: 'Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS', 'UltraSSD_LRS'. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.

See Azure Managed Disk Types for details on the disk types.

Upvotes: 3

Charles Xu
Charles Xu

Reputation: 31384

There are two ways to judge the disk type, SSD or HDD.

The first is that like the other answer describes, the StorageAccountType not only decide the disk redundancy, also decide the disk type. There are 4 values, but only the Standard_LRS means the HDD type and other mean SSD.

The second way is that use the PowerShell command to get the information of the disk itself like this:

$disk = Get-AzDisk -ResourceGroupName groupName -Name diskName

And the $disk.Sku also shows the disk type. The Sku name has 4 values: Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS. Only the value Standard_LRS means the HDD type, others mean SSD. You can see the description in the Azure Disk Template.

Upvotes: 2

Related Questions