Incorrect total size result from powershell
-
22-12-2019 - |
Question
I'm facing a problem which the result of getdrive is not accurate. Clueless.
As seen in the screenshots below, 10.1.105.203 has a total space of 7.81TB, but from what powershell gives me, it is only roughly 4TB. Pretty confusing here.
Solution
You're not really using PowerShell. You're using the Windows Scripting Host's object model, the precursor to PowerShell, from PowerShell. Try using either:
C:\PS> Get-Volume
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining Size
----------- --------------- ---------- --------- ------------ ------------- ----
C NTFS Fixed Healthy 94.34 GB 237.96 GB
Recovery NTFS Fixed Healthy 10.19 MB 300 MB
or
C:\PS> Get-WmiObject Win32_Volume | Format-Table DriveLetter,Capacity,FreeSpace
DriveLetter Capacity FreeSpace
----------- -------- ---------
C: 255505461248 101292863488
314568704 10682368
OTHER TIPS
You can also use Get-Psdrive to get the size of a drive.
PS C:\> Get-PSDrive -PSProvider filesystem
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
C 48.92 195.13 FileSystem C:\
D 30.82 69.18 FileSystem D:\
E .12 121.49 FileSystem E:\
You can always do a little manipulation to achieve multiple things with this, e.g,
PS C:\> Get-PSDrive -PSProvider filesystem | select Name, @{n= 'Used(GB)' ; e = {"{0:N2}" -f ($_.used/1GB)}}, @{n= 'Free
(GB)' ; e = {"{0:N2}" -f ($_.Free/1GB)}}, @{n= 'Total(GB)' ; e = {"{0:N2}" -f (($_.used + $_.Free)/1GB)}} | ft -auto
Name Used(GB) Free(GB) Total(GB)
---- -------- -------- ---------
C 48.92 195.13 244.04
D 30.82 69.18 100.00
E 0.12 121.49 121.62
Full agree with @Keith Hill, with the PowerShell way to get the result. The strange behaviour is that for your drive L:
, I can see that the total size is ok for the 10Tb drive, so I would not be surprise if you receive the same results from the new commands.
The next thing, I would check is if quotas are activated on your server.
You can also use :
Get-WmiObject Win32_logicaldisk -filter "driveType=4"