Problem: I need to figure out which volume corresponds to what partition(s) which corresponds to what disk in an extremely efficient script able manor. I know how to correspond which partition corresponds to what disk because the disk id is directly in the results of a simple wmic query. However, the first part of the problem is more difficult. How to correlate which volume belongs to which partitions?
Is there a way, using wmic, PowerShell, cmd prompt, to reverse-engineer which volume maps to which partition(s), that works across all currently supported versions of Windows Server (Windows Server 2008R2 - Windows Server 2016)?
If so how would this query look?
Using diskpart to get information is NOT an option. Although it can be used to script out disk operations, it is terrible to use diskpart as a tool to return information about disk configurations. Diskpart output is NOT parsible.
One possible solution, is the following power shell script. Output should be in JSON format. The problem with this solution is that it relies on the get-partition cmdlet. This cmdlet was introduced after windows 2008R2. This would work as a solution if the get-partition cmdlet were to be ported to windows 2008R2, or if I found a solution that would do the same thing on windows 2008R2. Although not a complete solution, it didn't fit as a comment.
I cannot currently post comments, however this seems very close to a solution for you. I found documentation from WMI Tasks entitled "...detect which drive letter is associated with a logical disk partition?" in VBScript.
Please note: I am by no means well versed in VBScript, so I cannot speak to how versatile and modifiable the below method is, however I believe it has all information needed to modify a new script that's parsable in a format to your liking.
Source: https://msdn.microsoft.com/en-us/library/aa394592(v=vs.85).aspx#code-snippet-11
When I test this script I get all requested information in
WScript.Echo
dialogs. As an example, on my system, the dialog shows: VBScript Dialog Output