How to remotely check Disk Space on Windows computers

Many people tend to use multiple devices. This includes their smartphones, personal laptops, desktops in offices and homes. Even after a great cloud-based integration with the services like OneDrive, some simple things really need the physical presence of the user to get some work done. One such simple thing is checking the disk space. If you are not physically present with a computer, it becomes really hard for a normal user to perform this simple task. So, in order to check how many partitions are present on that machine and by each partition, what is the total capacity of that partition is. Along with that, the free disk space and used disk space we would just need to run a simple script. So, without any further delay, let us just jump right in.

Check Disk Space on remote computers

First of all, this script would not work on every machine. It works only with Windows 10, Windows Server 2012, Windows Server 2012 R2, Windows Server 2008, Windows Server 2008 R2 and Windows 7. In my opinion, this should also work with Windows 8 and Windows 8.1 but it has not been tested yet. If you try it on Windows 8 and Windows 8.1, please feel free to share your results in the comment box below.

So, first of all, start by downloading this Powershell Script file from TechNet. You just need to save it on to your computer.

Then, open that same file using Notepad and you will see the code that will look something like this-

<# .Synopsis Gets Disk Space of the given remote computer name .DESCRIPTION Get-RemoteComputerDisk cmdlet gets the used, free and total space with the drive name. .EXAMPLE Get-RemoteComputerDisk -RemoteComputerName "abc.contoso.com" Drive UsedSpace(in GB) FreeSpace(in GB) TotalSpace(in GB) C 75 52 127 D 28 372 400 .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The component this cmdlet belongs to .ROLE The role this cmdlet belongs to .FUNCTIONALITY The functionality that best describes this cmdlet #>
function Get-RemoteComputerDisk
{
    
    Param
    (
        $RemoteComputerName="The Address Goes Here"
    )

    Begin
    {
        $output="Drive `t UsedSpace(in GB) `t FreeSpace(in GB) `t TotalSpace(in GB) `n"
    }
    Process
    {
        $drives=Get-WmiObject Win32_LogicalDisk -ComputerName $RemoteComputerName

        foreach ($drive in $drives){
            
            $drivename=$drive.DeviceID
            $freespace=[int]($drive.FreeSpace/1GB)
            $totalspace=[int]($drive.Size/1GB)
            $usedspace=$totalspace - $freespace
            $output=$output+$drivename+"`t`t"+$usedspace+"`t`t`t`t`t`t"+$freespace+"`t`t`t`t`t`t"+$totalspace+"`n"
        }
    }
    End
    {
        return $output
    }
}

Now, you will have to enter the address of your remote computer in the space marked above inside the quotes – The Address Goes Here.

Save the file.

Right click on the file and click on Run with Powershell. Click on Yes on the UAC or User Account Control Prompt that you get.

Now you will get your results on the Powershell terminal as in the format,

Check Disk Space on remote computers

Run this same file as per your wish.

You can read more about this here on TechNet.

Posted by on , in Category Windows with Tags
Ayush has been a Windows enthusiast since the day he got his first PC with Windows 98SE. He is an active Windows Insider since Day 1 and is now a Windows Insider MVP. He has been testing pre-release services on his Windows 10 PC, Lumia, and Android devices.