I am working in windows and I wanna to find out through command line disk capacity of remote windows servers.

For ex: I am @localhost, now I want to know whether D: drive of server is greater 10 GB or not. How can I check?

All servers are running windows OS


Using Powershell, you can use the following command:

Get-WmiObject -Class win32_logicalDisk -ComputerName server1, server2, server3, etc | Select-Object pscomputername, deviceid, freespace, size

Replace server1, server2, etc with the remote server names or IPs.

The output looks like this:

enter image description here

If you want, you can add | Export-Csv -Path .\drives.csv to the end of the script to output the file to a comma separated value (CSV) file for use with Excel. If you do, when you you open Excel you will need to format the drive size columns in Excel as numbers.

Just for giggles, I wrote this PowerShell script that will perform the task on all servers in Active Directory:

$ErrorActionPreference= 'silentlycontinue'

Get-ADComputer -Filter 'OperatingSystem -like "*Server*"' -Properties * | Select-Object Name |

ForEach-Object {
    If (Test-Connection $_.Name -Count 1){
        Get-WmiObject -Class win32_logicalDisk -ComputerName $_.Name | 
        Select-Object pscomputername, deviceid, freespace, size
    else {
        Write-host $_.Name " Connection Error"


Use the command fsutil:

fsutil volume diskfree C:
fsutil volume diskfree \\server\share

Output will be like:

Total # of free bytes        : 851127304192
Total # of bytes             : 2147480485888
Total # of avail free bytes  : 851127304192

To get only the line with the free bytes you may use:

fsutil volume diskfree C: | find /i "avail free"
  • FYI, this will require administrative credentials. – Bink Oct 29 '19 at 15:53

If you are in a domain, you would probably be able to do something with WMI (WMI example). If you are not in a domain, you can go two ways for remote monitoring:

  • Set up SNMP (excellent doc with guide) and write scripts to poll the SNMP daemon.
  • Use a monitoring product. I've used Opsview and Ninja in the past. Microsoft SCOM is also a good alternative (if you can afford the license fees).

If you have access to the network share and you have Cygwin installed you can do this command:

# df -h //myserver/shareddrive Filesystem Size Used Avail Use% Mounted on - 25G 13G 12G 52% //myserver/shareddrive


guys I also came with a solution using idea of fsutil and telnet:


  <job id="vbs">

  <script language="VBScript">

     set WshShell = WScript.CreateObject("WScript.Shell")
     WshShell.Run "telnet -l work"
     WScript.Sleep 500
     WshShell.AppActivate "Telnet"
     WScript.Sleep 500
     WshShell.SendKeys "y"
     WshShell.SendKeys "~"      
     WScript.Sleep 500
     WshShell.SendKeys "helloworld"
     WScript.Sleep 500
     WshShell.SendKeys "~"  
     WScript.Sleep 500
     WshShell.SendKeys "C:\Users\work2\Desktop\diskcheck.bat"   
     WScript.Sleep 200
     WshShell.SendKeys "~"




diskcheck.bat :

fsutil volume diskfree C:
Total # of free bytes        : 17084395520
Total # of bytes             : 249145847808
Total # of avail free bytes  : 17084395520
  • any improvements ? – rocko Jun 16 '14 at 4:25
  • I have never seen anyone install a telnet server on Windows, even the builtin one. Especially, since telnet has long since been considered insecure. – Keltari Nov 11 '19 at 12:45
Function GetRemoteDiskSpace (
$Drive = New-PSDrive -Name K -PSProvider FileSystem -Root "\\$TargetComputer\$Drive$" -Persist
$Info = Get-PSDrive $Drive 
$Free = $Info.Free /1GB
Remove-PSDrive -Name $drive -PSProvider FileSystem

return $Free
  • 1
    Welcome to Super User! Your contribution is welcome, but can you provide an explanation of the above function? :) – bertieb Apr 9 '18 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.