Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for a built-in Windows XP/Server 2003 utility that can pull drive information, similar to what the Disk Management mmc displays, including capacity and free space. Any ideas?

Diskpart doesn't seem to report free space and Disk Management doesn't seem to have an "export to text" feature. Any ideas?

Please note that I am not looking for any third-party tool recommendations. If it isn't a Windows built-in, I'll likely have to script it instead.

share|improve this question
    
do you need remote numbers or local? –  Jim B Jul 8 '09 at 20:09
    
Ideally, remote numbers -- but even if it's local I can run the utility remotely via a script or psexec. –  romandas Jul 8 '09 at 23:45

6 Answers 6

up vote 3 down vote accepted

For Windows XP and Server 2003, use the fsutil command

C:\Documents and Settings\administrator>fsutil volume diskfree C:
Total # of free bytes        : 14056869888
Total # of bytes             : 21459722240
Total # of avail free bytes  : 14056869888
share|improve this answer

DISKPART will show you this information at the volume level (for Windows Vista only)

DISKPART> detail volume

  Disk ###  Status      Size     Free     Dyn  Gpt
  --------  ----------  -------  -------  ---  ---
* Disk 0    Online        75 GB      0 B

Read-only              : No
Hidden                 : No
No Default Drive Letter: No
Shadow Copy            : No
Dismounted             : No
BitLocker Encrypted    : No

Volume Capacity        :   74 GB
Volume Free Space      :    8 GB
share|improve this answer
    
I don't get the same level of detail that you do. Are you running this against a Basic or Dynamic disk? I only get the initial table; I don't get "Read-only" or anything below that. –  romandas Jul 8 '09 at 19:22
    
My machine is a Windows Vista computer with Basic disks –  Kevin Kuphal Jul 8 '09 at 19:24
    
The version is 6.0.6002. My Windows 2003 server has version 5.2.3790.3959 and it does not have this detail. –  Kevin Kuphal Jul 8 '09 at 19:26
    
That must be it. On XP, the version I have is 5.1.3565 –  romandas Jul 8 '09 at 19:29
    
It may be weird, but version 6.0.6002 is included in the Vista automated installation kit (microsoft.com/downloads/…) and will work on Windows XP SP3 according to the Microsoft document for deploying XP on Netbooks. I don't know that I'd go through the trouble of downloading that huge kit just for this util, but if you're on XP SP3, just grab the file from a Vista machine. –  Kevin Kuphal Jul 8 '09 at 19:35

Every bit of information you could want regarding your logical disks:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim propValue
Dim objItem
Dim SWBemlocator
Dim UserName
Dim Password
Dim colItems

strComputer = "."
UserName = ""
Password = ""
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk",,48)
For Each objItem in colItems
    WScript.Echo "Access: " & objItem.Access
    WScript.Echo "Availability: " & objItem.Availability
    WScript.Echo "BlockSize: " & objItem.BlockSize
    WScript.Echo "Caption: " & objItem.Caption
    WScript.Echo "Compressed: " & objItem.Compressed
    WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    WScript.Echo "CreationClassName: " & objItem.CreationClassName
    WScript.Echo "Description: " & objItem.Description
    WScript.Echo "DeviceID: " & objItem.DeviceID
    WScript.Echo "DriveType: " & objItem.DriveType
    WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
    WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
    WScript.Echo "ErrorMethodology: " & objItem.ErrorMethodology
    WScript.Echo "FileSystem: " & objItem.FileSystem
    WScript.Echo "FreeSpace: " & objItem.FreeSpace
    WScript.Echo "InstallDate: " & objItem.InstallDate
    WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
    WScript.Echo "MaximumComponentLength: " & objItem.MaximumComponentLength
    WScript.Echo "MediaType: " & objItem.MediaType
    WScript.Echo "Name: " & objItem.Name
    WScript.Echo "NumberOfBlocks: " & objItem.NumberOfBlocks
    WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    for each propValue in objItem.PowerManagementCapabilities
    	WScript.Echo "PowerManagementCapabilities: " & propValue
    next
    WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
    WScript.Echo "ProviderName: " & objItem.ProviderName
    WScript.Echo "Purpose: " & objItem.Purpose
    WScript.Echo "QuotasDisabled: " & objItem.QuotasDisabled
    WScript.Echo "QuotasIncomplete: " & objItem.QuotasIncomplete
    WScript.Echo "QuotasRebuilding: " & objItem.QuotasRebuilding
    WScript.Echo "Size: " & objItem.Size
    WScript.Echo "Status: " & objItem.Status
    WScript.Echo "StatusInfo: " & objItem.StatusInfo
    WScript.Echo "SupportsDiskQuotas: " & objItem.SupportsDiskQuotas
    WScript.Echo "SupportsFileBasedCompression: " & objItem.SupportsFileBasedCompression
    WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    WScript.Echo "SystemName: " & objItem.SystemName
    WScript.Echo "VolumeDirty: " & objItem.VolumeDirty
    WScript.Echo "VolumeName: " & objItem.VolumeName
    WScript.Echo "VolumeSerialNumber: " & objItem.VolumeSerialNumber
Next
share|improve this answer

I'm not aware of any built-in option, I would just get all the info from WMI using VBScript or PowerShell.

share|improve this answer

Here's a very rough vbscript that I hacked together a while back.

This is actually part of an HTA that gives disk info in HTML. I stripped out all of the HTML for you and put in some tabs to make things line up a little.

Const BYTES_TO_GB = 1073741824

strComputer  = "computer"
Wscript.Echo "Disk Usage - " & strComputer & vbCrLf
Wscript.Echo "Volume" & vbTab & vbTab & "Size" & vbTab & _
   "Free" & vbTab & "% Free" & vbCrLf

Set objWMIService = GetObject("winmgmts://" & strComputer)
Set colLogicalDisk = objWMIService.ExecQuery( _
    "SELECT DeviceID,VolumeName,Size,FreeSpace FROM Win32_LogicalDisk WHERE DriveType=3")

For Each objLogicalDisk In colLogicalDisk
  intTotalSize = objLogicalDisk.Size / BYTES_TO_GB
  intFreeSpace = objLogicalDisk.FreeSpace / BYTES_TO_GB
  Wscript.Echo objLogicalDisk.VolumeName & " (" & objLogicalDisk.DeviceID & ")" & _
    vbTab & FormatNumber(intTotalSize,0) & " GB" & _
    vbTab & FormatNumber(intFreeSpace,0) & " GB" & _
    vbTab & FormatNumber(intFreeSpace/intTotalSize*100,0) & " %"
Next

Obviously, you'll need to fill in a value for strComputer. You can also adjust the constant if you like GiB instead of GB.

Hope this helps.

share|improve this answer

the technology you are looking for is WMI. For an overview on how to script for it see: WMI scripting primer.

WMI is the best way to handle remote systems managment. WMI can also be used with Powershell, but you are likley to see (for now) most examples in vbscript. Once you understand the concepts you can use the scriptomatic (vbscript) (powershell) to build your scripts

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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