Skip to content

PowerShell: Check Remote Computer Disk Capacity

From time to time, I get tickets where one of many possible root causes may be a full disk. While accessing this information over RDP is often an option, it is rather more intrusive than needed. What’s more, I usually don’t have access to access file servers over RDP. Enter PowerShell and the get-WmiObject query!

By using the Win32_LogicalDisk class, and specifying the computer I want to access with the -ComputerNameparameter, I get the information readily enough. The complete query looks like this:

get-WmiObject win32_logicaldisk -Computername ComputerID

The output looks like this:

Screenshot of Powershell query, showing the results of the query:

DeviceID     : C:
DriveType    : 3
ProviderName : 
FreeSpace    : 440359514112
Size         : 510914457600
VolumeName   : OSDisk

DeviceID     : I:
DriveType    : 4
ProviderName : \\REDACTED
FreeSpace    : 244771405824
Size         : 1073738674176
VolumeName   : Data1

DeviceID     : K:
DriveType    : 4
ProviderName : \\REDACTED
FreeSpace    : 244771405824
Size         : 1073738674176
VolumeName   : Data1

As you can see from the screenshot above, the output returns FreeSpace in Bytes. Divide by 1’024, 1’048’576, or 1’073’741’824 to get available space in KB, MB, or GB, respectively (though a thousand, a million, and a billion should get you close enough for government work).

You might also note that the output lists ALL mapped drives, including mapped network drives, which means that the command is also useful to see whether a drive is mapped, and whether it’s mapped correctly.

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

This site uses Akismet to reduce spam. Learn how your comment data is processed.