I'm currently working on vbscript to report disk, partition, and logical drive usage and size data, in an exact way, in bytes. I use several WMI queries of Win32_DiskDrive, Win32_DiskPartition, Win32_LogicalDisk with associations. In some certain circumstances I've got interesting results, where the size of the disk is less then the size of the partitions on it.
In my experiences I've got these results from disks provided by the virtualisation layer, or by SAN connections.
For example:
Win32_LogicalDiskToPartition shows:
Antecedent : \\xxxxx\root\cimv2:Win32_DiskPartition.DeviceID="Disk #2, Partition #0" Dependent : \\xxxxx\root\cimv2:Win32_LogicalDisk.DeviceID="T:" EndingAddress : 1099510579199 StartingAddress : 1048576
from this data, the size should be 1 099 509 530 624 bytes and the EndingAddress: 1 099 510 579 199
the corresponding Win32_DiskPartition shows:
NumberOfBlocks : 2147479552 BootPartition : False Name : Disk #2, Partition #0 PrimaryPartition : True Size : 1099509530624 Index : 0
which is Ok, but the corresponding Win32_DiskDrive shows:
Partitions : 1 DeviceID : \\.\PHYSICALDRIVE2 Model : IBM 2145 Multi-Path Disk Device Size : 1099506078720 Caption : IBM 2145 Multi-Path Disk Device
The size is: 1 099 506 078 720
So the partition is greater then the disk.
From the MSDN library: https://msdn.microsoft.com/en-us/library/aa394132%28v=vs.85%29.aspx
- Size
-
- Data type: uint64
- Access type: Read-only
- Qualifiers: Units (Bytes)
Size of the disk drive. It is calculated by multiplying the total number of cylinders, tracks in each cylinder, sectors in each track, and bytes in each sector.
For more information about using uint64 values in scripts, see Scripting in WMI.
- TotalCylinders
-
- Data type: uint64
- Access type: Read-only
Total number of cylinders on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications.
Example: 657
For more information about using uint64 values in scripts, see Scripting in WMI.
By the above property definitions, the disk size can be inaccurate.
Does anybody know a way to get the accurate disk size using wmi, or any script technique?