1

I'm trying to know which VHDs are used for a specific storage pool. Using the cross platform CLI I am able to get the LUN and the blob name:

$ azure vm disk list testvm
info:    Executing command vm disk list
+ Fetching disk images                                                         
+ Getting virtual machines                                                     
+ Getting VM disks                                                             
data:    Lun  Size(GB)  Blob-Name                                         OS     
data:    ---  --------  ------------------------------------------------  -------
data:         128       testvm-testvm-os-1457591813350.vhd                Windows
data:    0    1023      testvm-disk1.vhd                                  
data:    1    1023      testvm-disk2.vhd                                  
data:    2    1023      testvm-disk3.vhd                                  
data:    3    1023      testvm-disk4.vhd

Within the VM using the Device Manager application for the storage pool, I am able to get the drive letter, the friendly name, the disk size, the disk ID (the same one that is reported by diskpart), and in the Details tab, there is information about Power Relations that list the LUN:

SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000003
SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000001
SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000002
SCSI\Disk&Ven_Msft&Prod_Virtual_Disk\000000

I am now trying to get the same information through PowerShell, but the best I can find is the friendly name of the VHDs, which isn't very useful in this context:

PS C:\Users\vpjtech> Get-StoragePool -FriendlyName Data | Get-PhysicalDisk

FriendlyName            CanPool                 OperationalStatus       HealthStatus            Usage                                     Size
------------            -------                 -----------------       ------------            -----                                     ----
PhysicalDisk2           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk5           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk3           False                   OK                      Healthy                 Auto-Select                         1022.25 GB
PhysicalDisk4           False                   OK                      Healthy                 Auto-Select                         1022.25 GB

Using Get-WmiObject I am able to get the LUN, but I do not see how I can link this information with the storage pool:

PS C:\Users\vpjtech> Get-WmiObject -Class Win32_SCSIControllerDevice

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.DeviceID=\"ROOT\\\\SPACEPORT\
                      \\\0000\"",Dependent="\\\\TESTVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\\\DISK\\\\{BED09DDF-E9A5-11E5-8
                      0C0-000D3A404FE8}\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \\TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.De
                      viceID=\"ROOT\\\\SPACEPORT\\\\0000\"",Dependent="\\\\TESTVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"STORAGE\\\\DI
                      SK\\\\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}\""
AccessState         : 
Antecedent          : \\TESTVM\root\cimv2:Win32_SCSIController.DeviceID="ROOT\\SPACEPORT\\0000"
Dependent           : \\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\\DISK\\{BED09DDF-E9A5-11E5-80C0-000D3A404FE8}"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TESTVM\\root\\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000000\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \\TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TES
                      TVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000000\""
AccessState         : 
Antecedent          : \\TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000000"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TESTVM\\root\\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000001\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \\TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TES
                      TVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000001\""
AccessState         : 
Antecedent          : \\TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000001"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TESTVM\\root\\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000002\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \\TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TES
                      TVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000002\""
AccessState         : 
Antecedent          : \\TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000002"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

__GENUS             : 2
__CLASS             : Win32_SCSIControllerDevice
__SUPERCLASS        : CIM_ControlledBy
__DYNASTY           : CIM_Dependency
__RELPATH           : Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.DeviceID=\"VMBUS\\\\{BA6163D9
                      -04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TESTVM\\root\\cimv2:Win
                      32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000003\""
__PROPERTY_COUNT    : 7
__DERIVATION        : {CIM_ControlledBy, CIM_DeviceConnection, CIM_Dependency}
__SERVER            : TESTVM
__NAMESPACE         : root\cimv2
__PATH              : \\TESTVM\root\cimv2:Win32_SCSIControllerDevice.Antecedent="\\\\TESTVM\\root\\cimv2:Win32_SCSIController.De
                      viceID=\"VMBUS\\\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\\\{F8B3781B-1E82-4818-A1C3-63D806EC15BB}\"",Dependent="\\\\TES
                      TVM\\root\\cimv2:Win32_PnPEntity.DeviceID=\"SCSI\\\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\\\000003\""
AccessState         : 
Antecedent          : \\TESTVM\root\cimv2:Win32_SCSIController.DeviceID="VMBUS\\{BA6163D9-04A1-4D29-B605-72E2FFB1DC7F}\\{F8B3781B-1E82-
                      4818-A1C3-63D806EC15BB}"
Dependent           : \\TESTVM\root\cimv2:Win32_PnPEntity.DeviceID="SCSI\\DISK&VEN_MSFT&PROD_VIRTUAL_DISK\\000003"
NegotiatedDataWidth : 
NegotiatedSpeed     : 
NumberOfHardResets  : 
NumberOfSoftResets  : 
PSComputerName      : TESTVM

There ought to be a way but I fail to wrap my head around it.

1

According to your description, I test in my lab. Maybe you could use the cmdlet below:

Get-WmiObject Win32_DiskDrive | ForEach-Object {
  $disk = $_
  $partitions = "ASSOCIATORS OF " +
                "{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
                "WHERE AssocClass = Win32_DiskDriveToDiskPartition"
  Get-WmiObject -Query $partitions | ForEach-Object {
    $partition = $_
    $drives = "ASSOCIATORS OF " +
              "{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
              "WHERE AssocClass = Win32_LogicalDiskToPartition"
    Get-WmiObject -Query $drives | ForEach-Object {
      $driveLetter = $_.DeviceID
      $fltr        = "DriveLetter='$driveLetter'"
      New-Object -Type PSCustomObject -Property @{
        Disk        = $disk.PNPDeviceID
        DriveLetter = $driveLetter
        VolumeName  = $_.VolumeName
        VolumeID    = Get-WmiObject -Class Win32_Volume -Filter $fltr |
                      Select-Object -Expand DeviceID
        Size        = $disk.Size
      } |ft -AutoSize
    }
  }
}

enter image description here Regards,

Walter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.