0

I need to query System Center Configuration Manager (current branch, version 1606) for information about the disks, partitions and volumes of client computers.

However, there doesn't seem to be any way to correlate logical disks to physical disks and partitions; those data are presented as three different classes in the Resource Explorer, and even the corresponding database tables and views provide no way to link a logical disk to a physical disk and a partition (while instead a partition can at least be linked to its physical disk).

Unfortunately, this seems to be a well known issue in Windows systems, quite hard to get around even when using WMI:
https://blogs.technet.microsoft.com/heyscriptingguy/2005/05/23/how-can-i-correlate-logical-drives-and-physical-disks
https://stackoverflow.com/questions/4822559/powershell-and-wmi-how-to-map-logical-disk-volumes-to-a-hard-disk-or-vice-versa

Can this really be so hard? Is it possible at all to retrieve from SCCM a list of logical disks and the physical disks and partitions where they reside?

Massimo
  • 68,714
  • 56
  • 196
  • 319

2 Answers2

0

SCCM doesn not retrieve this information on its own, but there is a WMI class exposing it: Win32_LogicalDiskToPartition.

The class needs to be added to SCCM's hardware inventory Configuration; after the data are retrieved, it becomes possible to use them to join logical disks to physical partitions; some string manipulation is required, because the class exposes partitions and disks in the following format:

\\HOSTNAME\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
\\HOSTNAME\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
Massimo
  • 68,714
  • 56
  • 196
  • 319
-1

Please refer to the following query:

  Select * from v_GS_DISK
  Select * from v_GS_PARTITION
  Select * from v_GS_LOGICAL_DISK

  Select di.DeviceID0,pa.DeviceID0,ld.DeviceID0,* from v_GS_LOGICAL_DISK LD
  inner join v_GS_PARTITION PA
  ON LD.ResourceID=PA.ResourceID
  inner join v_GS_DISK DI 
  ON DI.ResourceID=PA.ResourceID
  • 1
    This is completely wrong. You are joining the three tables on the "ResourceID" column, which identifies the **computer**. If a system has one disk with three partitions and two logical volumes (such as a boot partition and two NTFS partitions), this will produce *six rows*, and things will get even worse with multiple disks. – Massimo Apr 06 '17 at 11:33