Mapping the Volume GUID to the physical disk and partion - I'm stuck!

Howdy Y'all from Texas.  I've got to say I've really enjoyed Scripting Guys blog.  I've been referencing it for some time now and have really learned a bunch from it.

I am, however, currently stuck on a problem and I've not been able to hunt up something applicable.

What I need to do is figure out how to map a Volume GUID to whatever Disk and Partition that stores the actual data.  I understand that a volume may have multiple such extents although for me they would be rather rare.  Sometimes I have only a volume id which looks like: \\?\Volume{b077d0f3-bcb3-494e-8803-d2bf22835f2d}\ and is not mapped to a drive letter.  Which Disk(s) and Partition(s) physically comprise the volume?

So for example:  \\?\Volume{b077d0f3-bcb3-494e-8803-d2bf22835f2d}\ => Disk # 2, Partition # 3

I've figured out how to get the volumes with a drive letter mapped, but not how to get ones without a drive letter.

August 19th, 2013 4:52pm

Try this:

Get-WmiObject -class Win32_Volume -computername localhost | 
     where-object {$_.name -like "\\?\*"} |
     select-object label, name, capacity, freespace |
     format-list

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2013 5:31pm

Thank you, but the Win32_Volume class doesn't have anything in it that shows the disk # and Partition # or, that I can find, a linkage to something that does.

The properties of label, name, capacity, freespace don't directly point to the exact disk and partition, but they do help me narrow it if I'm using the "Mark-1 Eyeball" method.  I'm trying to get to something that says Volume xyz is on disk a, partition b type of thing.

An example would be two new empty 100 GB Virtual Disks on a VM Guest.  Which one is which?

August 19th, 2013 5:38pm

Aaaaggghhh, So Close.  Been hunting for days now.

I found this using the Powershell CIM stuff just a minute ago and thought I had it.

get-volume | foreach {$_.ObjectID; get-partition -Volume $_}

This shows what I'm looking for, but returns nothing on the Get-Partition if the drive letter isn't there.  Same roadblock I'm hitting whichever method I've tried.  I had to run it elevated too which isn't optimal.  I found this http://blogs.msdn.com/b/dsadsi/archive/2010/03/19/mapping-volumeid-to-disk-partition-using-the-deviceiocontrol-api.aspx and it says WMI doesn't have a way and provides the source of a program to do it. 

Still hoping.

Free Windows Admin Tool Kit Click here and download it now
August 19th, 2013 6:28pm

Fingers' crossed

get-partition | fl AccessPaths, Guid, DiskNumber, PartitionNumber

Guid doesn't always have the volume name, but when it doesn't AccessPaths does!

August 19th, 2013 6:35pm

Still has the PermissionDenied error if I don't elevate the PS process which is a PITA.
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2013 6:38pm

Presto, all it takes is admitting ignorance on a forum ...

Here is what I came up with (powershell run as administrator):

$CimPartInfo = get-partition 
foreach ($CimPart in $CimPartInfo) {
    if ($CimPart.Guid -eq $null) {
        $PartGUID = [regex]::match($CimPart.AccessPaths, 'Volume({[^}]+})').Groups[1].Value
        }
     else {
        $PartGUID = $CimPart.Guid
        }
    "Volume GUID $PartGUID"
    "`tDisk #     :`t$($CimPart.DiskNumber)"
    "`tPartition #:`t$($CimPart.PartitionNumber)"
    "`tDriveLetter:`t$($CimPart.DriveLetter)"
    } #foreach CimPart

August 19th, 2013 7:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics