The value of size
that wmic logicaldisk get size
returns is basically the advertised size of the hard drive. However, I am trying to obtain the total disk size minus the reserved space.
Since I could not figure out how to retrieve this value from diskpart
list disk
without launching an actual instance of command prompt, I am now trying to obtain it from PowerShell with the code below.
cp.exec('get-volume', {'shell': 'powershell.exe'}, (error, stdout)=>{
console.log(stdout)
})
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- ------------ -------------- --------- ------------ ----------------- ------------- ----
D [removed] NTFS Fixed Healthy OK 930.74 GB 930.91 GB
C System NTFS Fixed Healthy OK 520.67 GB 930.88 GB
NTFS Fixed Healthy OK 112.01 MB 450 MB
Recovery NTFS Fixed Healthy OK 109.23 MB 529 MB
Recovery NTFS Fixed Healthy OK 73.03 MB 499 MB
The problem is that when the PowerShell query is narrowed to get-volume | format-list size
, it reverts to returning the advertised size of the disk.
size : 999558213632 // basically 1TB instead of 930 GB
Why does it revert back to the advertised size?
Does anybody know how I can obtain the practical size of the disk (i.e. 930 GB)?