Code:
1: strComputer = "."
2: Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
3:
4: Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
5: For Each objDrive In colDiskDrives
6: WScript.Echo "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
7: strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
8: Set colPartitions = objWMIService.ExecQuery _
9: ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
10: strDeviceID & """} WHERE AssocClass = " & _
11: "Win32_DiskDriveToDiskPartition")
12: For Each objPartition In colPartitions
13: WScript.Echo "Disk Partition: " & objPartition.DeviceID
14: Set colLogicalDisks = objWMIService.ExecQuery _
15: ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
16: objPartition.DeviceID & """} WHERE AssocClass = " & _
17: "Win32_LogicalDiskToPartition")
18: For Each objLogicalDisk In colLogicalDisks
19: WScript.Echo "Logical Disk: " & objLogicalDisk.DeviceID
20: Next
21: WScript.Echo
22: Next
23: WScript.Echo
24: Next