How to get the SCSI target ID and port number of a vhd on Hyper-V server? RRS feed

  • Question

  • I am looking for a way to corelate VHDs of a vitual machine with disk drives on the guest VM of Hyper-V. I beleive SCSI controller attributes like target ID, bus no, port no and Lun ID can be used for corelation. I have checked these attributes on few guests and realized that SCSI target and bus no are 0,0 respectively for all the disks. Only the differentitaing attributes left are lun ID and SCSI port number. But unfortunately I am unable to get the SCSI port no and SCSI target ID of the VHD on the server. Can someone please let me know how to get these attributes on the server through WMI?

    I have googled quite a bit and found that Msvm_MountedStorageImage clas has these SCSI controller attributes, but I am unable to fetch the instances of this class on my server(I have tried with almost all VHDs mounted and unmounted, but unable to get a single instance). I am not sure if this class instance exists for VHDs assigned to IDE and SCSI controllers irrespective of volume mount status on the guest VM. It would be helpful if anyone can share some information related to this class.

    Please let me know if any other attributes exist for VHD(Server) to disk drive(Guest) corelation.

    Thanks in advance for your valuable time and suggestions!     

    Friday, March 30, 2012 11:08 AM

All replies

  • For Msvm_MountedStorageImage WMI class, you need to manually mount VHD file. For instance, you can do that with powershell cmdlet Mount-VM.

    Once you do that, you can again run powershell cmdlet as follows to get what you need.

    Get-WmiObject -Namespace root\virtualization -query "select * from Msvm_MountedStorageImage".

    Not sure if that is the kind of scenario you are looking for but the above should help you to get something from WMI. HTH.

    Saturday, March 31, 2012 5:33 AM
  • What happens exactly when I mount VHD with Mount-VM? I am bit confused here. The VHD is provisioned to guest and I have assigned a drive letter as well(mounted already). Do we need to mount it again on the server? Can you please explain?

    If somehow this works, do I need to mount all the VHDs to get the required attributes and unmount them? 


    Sunday, April 1, 2012 9:59 AM
  • Is there a way to get the SCSI controller instance ID(GUID) on the guest VM? Some blogs mentioned, the PNP ID of the controller is same as SCSI controller instance ID(GUID). But, it is not the case on the setups which I have checked.

    Is there any SDK API atleast to get the SCSI target and port of the VHD on Hyper-V host? I would really appreciate any helpful suggestions.

    I was able to complete this kind of corelation quite easily on other virtualization technologies like VMWARE and LPAR. I am facing lot of difficulties on Hyper-V starting from day 1. Is Hyper-V API is not matured enough or is it lacking proper documentation or am I missing the actual docs?


    Tuesday, April 3, 2012 6:01 AM