List details about Disks attached to Azure Virtual Machines such as DiskName, AttachedTo, DiskSizeInGB etc

The following article will demonstrate how to gather details about the Disks attached to your  Azure VM’s via PowerShell commands.

First step is to verify you are in the correct Azure Subscription. To connect to the correct subscription you want to report on you can do the following:

PS C:\> Select-AzureSubscription

cmdlet Select-AzureSubscription at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) SubscriptionName: Subscription4

Now the commands you run will run against “subscription4″ instead of the default subscription. Substitute your subscription name for Subscription4 of course.

Once you are in the correct subscription you can run the following command. This will bring back the following values.

DiskName, AttachedTo, DiskSizeInGB, OS

C:\> Get-AzureDisk | Get-AzureDisk | Format-list  DiskName, AttachedTo, DiskSizeInGB, OS > c:\files\disks.txt

DiskName     : Server1-Server1-2012-12-19 AttachedTo   : RoleName: Server1                DeploymentName: Server1                HostedServiceName: Server1 DiskSizeInGB : 80 OS           : Windows

DiskName     : Server2-Server2-2012-12-06 AttachedTo   : DiskSizeInGB : 80 OS           : Windows

DiskName     : Server3-Server3-0-20130122173456 AttachedTo   : RoleName: Server3                DeploymentName: Server3                HostedServiceName: Server3 DiskSizeInGB : 30 OS           : Windows

DiskName     : Server4-Server4-0-201301221737689 AttachedTo   : RoleName: Server4                DeploymentName: Server4                HostedServiceName: Server4 DiskSizeInGB : 120 OS           : Windows

The entire list of values for this command are as follows. Meaning, after the format list part of the above command, you can specify any of these values.

AffinityGroup
AttachedTo
IsCorrupted
Label
Location
DiskSizeInGB
MediaLink
DiskName
SourceImageName
OS
OperationDescription
OperationId
OperationStatus

Share Button
Author: JA


Leave a Reply

Your email address will not be published. Required fields are marked *