none
WMI MSFT_Disk Location returns strange value RRS feed

  • Question

  • I am trying to retrieve information about drive physical locations, such as Location path in DiskPart (strings like PCIROOT(0)#PCI(0100)#ATA(C01T03L00)https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/hard-disk-location-path-format

    I found that WMI MSFT_Disk class (Win 8+) has Location property which should return this string according to the docs https://msdn.microsoft.com/en-us/library/windows/desktop/hh830493(v=vs.85).aspx

    It works fine on one laptop and even in VMWare VM (tested with wmic /namespace:\\Root\Microsoft\Windows\Storage path msft_disk get model, location in admin cmd):
       
        Location                                                              Model
        PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T00L00)  VMware Virtual S
        PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T01L00)  VMware Virtual S
        PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T02L00)  VMware Virtual S

    But on my PC (latest Win10, Asus Z87 Motherboard) I get output like this

        Location                                 Model
        Integrated : Adapter 2 : Port 3  Samsung SSD 850 PRO 512GB
        Integrated : Adapter 2 : Port 4  WDC WD10EZRX-00A8LB0
        ...
        Integrated : Adapter 0 : Port 0  Transcend 16GB
        Integrated : Adapter 0 : Port 0  Elements 25A2
    while in DiskPart they are in the expect format (PCIROOT(0)#PCI(1F02)#ATA(C03T00L00) for the first drive). Locations for USB drives (the last two) are still not available, but I mostly care about SATA.

    Is it a bug? :) Is there any other easy way to retrieve these strings except combining results from APIs described in the DiskPart docs?

    • Edited by AlexP11223 Thursday, March 1, 2018 9:39 AM
    • Moved by Bill_Stewart Monday, July 29, 2019 8:28 PM This is not "scripts on demand"
    Thursday, March 1, 2018 9:38 AM

All replies

  • Virtual disks and SATA disks are not the same hardware types and have different location strings.  There is no way to make a Vdisks and a SATA/USB look the same. 

    What is the purpose of this exercise?


    \_(ツ)_/

    Thursday, March 1, 2018 1:51 PM
  • It's not about VM, it's just one of the cases where it worked as expected, as specified in the docs.

    The docs don't say that format like "Integrated : Adapter 2 : Port 3" is possible.

    I just need to identify (persistent across restarts and HDD replacements) physical location of SATA HDD. Not from VM.

    That is I retrieved some string, then shutdown, changed HDD in this SATA port and that string should remain the same.

    I guess "Integrated : Adapter 2 : Port 3" will work fine too, but it's weird that it's not the same format as in the docs or DiskPart.


    • Edited by AlexP11223 Thursday, March 1, 2018 2:10 PM
    Thursday, March 1, 2018 2:06 PM
  • You are still not saying why you need this in that specific format.

    What is the purpose and use of this?


    \_(ツ)_/

    Thursday, March 1, 2018 2:26 PM
  • I guess any format will work (as long as it is persistent as I described), I just don't like undocumented behavior :)

    + if it is in some specific format, then it could be possible to extract some info for more friendly output.
    • Edited by AlexP11223 Thursday, March 1, 2018 2:40 PM
    Thursday, March 1, 2018 2:33 PM
  • The behavior is correctly documented.  The format of "Location" depends on the disk type.  SCSI, SATA, SAS, all are different.

    You should probably be using Win32_Volume or Win32_PhysicalDisk.


    \_(ツ)_/

    Thursday, March 1, 2018 2:47 PM
  • No, it says that only two formats possible:

    "A string that contains the PnP location path of the disk. The format of this string depends on the bus type. If the bus type is SCSI, SAS, or PCI RAID, the format is AdapterPnpLocationPath#BusType(PPathIdTTargetIdLLunId). If the bus type is IDE, ATA, PATA, or SATA, the format is AdapterPnpLocationPath#BusType(CPathIdTTargetIdLLunId)."

    Also it seems to include to include more information than there 2 numbers in my case...

    Volume? Why would it include info about the drive physical location? And in Win32_PhysicalMedia I don't see anything like this too, it seems to be more about the device itself.


    • Edited by AlexP11223 Thursday, March 1, 2018 3:07 PM
    Thursday, March 1, 2018 3:06 PM
  • And those are the two formats you are getting.  If you think the documentation is bad then this is not the correct place to complain.  Post to "UserVoice" for bugs and doc issues.

    Non-PnP devices that are integrated on the motherboard are not PnP path devices at thee hardware level.  They are later added as PnP devices by the vendor's drivers.

    To get the PnP path of most devices use Win32_PnpEntity

    Get-WmiObject  Win32_PnpEntity | Select PnPDeviceId, HardwareId

    OR

    Get-WmiObject Win32_DiskDrive|select PNPDeviceID


    \_(ツ)_/


    • Edited by jrv Thursday, March 1, 2018 3:16 PM
    • Proposed as answer by jrv Tuesday, July 2, 2019 9:05 PM
    Thursday, March 1, 2018 3:15 PM
  • > And those are the two formats you are getting.

    No, that's exactly what I was complaining about :) On my PC I am getting "Integrated : Adapter X : Port Y" for all devices (also for all USB drives it's 0, which I guess means that this info is not available for them).


    • Edited by AlexP11223 Thursday, March 1, 2018 3:51 PM
    Thursday, March 1, 2018 3:50 PM
  • Hi Alex, 

    Were you able to figure out this problem? I have the same issue I need to get the documented value but I get same as you "Intergated : Adapter 0"


    Tuesday, July 2, 2019 8:58 PM
  • This topic is almost 2 years old,  Why bother with it.  The user abandoned it a long time ago.


    \_(ツ)_/

    Tuesday, July 2, 2019 9:04 PM
  • No, I think I ended up using some other API, probably SetupAPI.
    Tuesday, July 2, 2019 9:15 PM
  • No, I think I ended up using some other API, probably SetupAPI.

    Ok.  The answer was given above.  To e clear.  The location you posted says that the devices are attached to the "on-board" adapters 0 and 2 and shows the ports they are connected or assigned to.   This is the normal behavior and report for "storage" devices. There is no trick here. It is a pure hardware designation.


    \_(ツ)_/

    Tuesday, July 2, 2019 9:19 PM
  • Is it possible for you to dig it out? I am quite stuck and don't want to use diskpart.exe



    Wednesday, July 3, 2019 6:56 PM
  • I used SetupApi to enumerate USB devices and retrieve some info about ports.

    Look into SetupDiGetClassDevs((LPGUID)&GUID_CLASS_USB_HOST_CONTROLLER, ...), SetupDiEnumDeviceInfo, SP_DEVICE_INTERFACE_DATA, SP_DEVICE_INTERFACE_DETAIL_DATA, IOCTL_USB_GET_ROOT_HUB_NAME, IOCTL_USB_GET_NODE_CONNECTION_NAME, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX

    It can retrieve info like in the Device Manager.
    • Edited by AlexP11223 Wednesday, July 3, 2019 7:23 PM
    Wednesday, July 3, 2019 7:22 PM
  • SetupAPI s what is called by Win32_PnPEntity and other WMI device classes.

    The following will get all physical disk devices on the system.

    Get-WmiObject Win32_PnPEntity  | Where{ $_.PnPClass -eq 'DiskDrive'}| select name,pnpclass, DeviceId


    \_(ツ)_/


    • Edited by jrv Wednesday, July 3, 2019 8:05 PM
    Wednesday, July 3, 2019 8:05 PM