Win32_LogicalDisk class

The Win32_LogicalDisk WMI class represents a data source that resolves to an actual local storage device on a computer system running Windows.

The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties are listed in alphabetic order, not MOF order.

Syntax

[Dynamic, Provider("CIMWin32"), SupportsUpdate, UUID("{8502C4B7-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT]
class Win32_LogicalDisk : CIM_LogicalDisk
{
  uint16   Access;
  uint16   Availability;
  uint64   BlockSize;
  string   Caption;
  boolean  Compressed;
  uint32   ConfigManagerErrorCode;
  boolean  ConfigManagerUserConfig;
  string   CreationClassName;
  string   Description;
  string   DeviceID;
  uint32   DriveType;
  boolean  ErrorCleared;
  string   ErrorDescription;
  string   ErrorMethodology;
  string   FileSystem;
  uint64   FreeSpace;
  datetime InstallDate;
  uint32   LastErrorCode;
  uint32   MaximumComponentLength;
  uint32   MediaType;
  string   Name;
  uint64   NumberOfBlocks;
  string   PNPDeviceID;
  uint16   PowerManagementCapabilities[];
  boolean  PowerManagementSupported;
  string   ProviderName;
  string   Purpose;
  boolean  QuotasDisabled;
  boolean  QuotasIncomplete;
  boolean  QuotasRebuilding;
  uint64   Size;
  string   Status;
  uint16   StatusInfo;
  boolean  SupportsDiskQuotas;
  boolean  SupportsFileBasedCompression;
  string   SystemCreationClassName;
  string   SystemName;
  boolean  VolumeDirty;
  string   VolumeName;
  string   VolumeSerialNumber;
};

Members

The Win32_LogicalDisk class has these types of members:

Methods

The Win32_LogicalDisk class has these methods.

Method Description
Chkdsk Invokes the Chkdsk operation on the disk.
ExcludeFromAutochk Excludes disks from the Chkdsk operation to be run at the next restart.
Reset Not implemented. For more information about how to implement this method, see the Reset method in CIM_LogicalDisk for documentation.
ScheduleAutoChk Schedules Chkdsk to be run at the next restart if the dirty bit has been set.
SetPowerState Not implemented. For more information about how to implement this method, see the SetPowerState method in CIM_LogicalDisk.

Properties

The Win32_LogicalDisk class has these properties.

Access

Data type: uint16

Access type: Read-only

Type of media access available.

This property is inherited from CIM_StorageExtent.

Unknown (0)

Readable (1)

Writeable (2)

Writable

Read/Write Supported (3)

Write Once (4)

Availability

Data type: uint16

Access type: Read-only

Qualifiers: MappingStrings ("MIF.DMTF|Operational State|003.5", "MIB.IETF|HOST-RESOURCES-MIB.hrDeviceStatus")

Availability and status of the device.

This property is inherited from CIM_LogicalDevice.

Other (1)

Unknown (2)

Running/Full Power (3)

Running or Full Power

Warning (4)

In Test (5)

Not Applicable (6)

Power Off (7)

Off Line (8)

Offline

Off Duty (9)

Degraded (10)

Not Installed (11)

Install Error (12)

Power Save - Unknown (13)

The device is known to be in a power save mode, but its exact status is unknown.

Power Save - Low Power Mode (14)

The device is in a power save state, but still functioning, and may exhibit degraded performance.

Power Save - Standby (15)

The device is not functioning, but could be brought to full power quickly.

Power Cycle (16)

Power Save - Warning (17)

The device is in a warning state, but also in a power save mode.

Paused (18)

The device is paused.

Not Ready (19)

The device is not ready.

Not Configured (20)

The device is not configured.

Quiesced (21)

The device is quiet.

BlockSize

Data type: uint64

Access type: Read-only

Qualifiers: MappingStrings ("MIB.IETF|HOST-RESOURCES-MIB.hrStorageAllocationUnits"), Units ("bytes")

Size, in bytes, of the blocks that form this storage extent. If unknown or if a block concept is not valid (for example, for aggregate extents, memory or logical disks), enter 1.

This property is inherited from CIM_StorageExtent.

For more information about using uint64 values in scripts, see Scripting in WMI.

Caption

Data type: string

Access type: Read-only

Qualifiers: MaxLen (64), DisplayName ("Caption")

Short description of the object a one-line string.

This property is inherited from CIM_ManagedSystemElement.

Compressed

Data type: boolean

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|File System Functions|GetVolumeInformation|FS_VOL_IS_COMPRESSED")

If True, the logical volume exists as a single compressed entity, such as a DoubleSpace volume. If file based compression is supported, such as on NTFS, this property is False.

ConfigManagerErrorCode

Data type: uint32

Access type: Read-only

Qualifiers: Schema ("Win32")

Windows Configuration Manager error code.

This property is inherited from CIM_LogicalDevice.

This device is working properly. (0)

Device is working properly.

This device is not configured correctly. (1)

Device is not configured correctly.

Windows cannot load the driver for this device. (2)

The driver for this device might be corrupted, or your system may be running low on memory or other resources. (3)

Driver for this device might be corrupted, or the system may be low on memory or other resources.

This device is not working properly. One of its drivers or your registry might be corrupted. (4)

Device is not working properly. One of its drivers or the registry might be corrupted.

The driver for this device needs a resource that Windows cannot manage. (5)

Driver for the device requires a resource that Windows cannot manage.

The boot configuration for this device conflicts with other devices. (6)

Boot configuration for the device conflicts with other devices.

Cannot filter. (7)

The driver loader for the device is missing. (8)

Driver loader for the device is missing.

This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. (9)

Device is not working properly. The controlling firmware is incorrectly reporting the resources for the device.

This device cannot start. (10)

Device cannot start.

This device failed. (11)

Device failed.

This device cannot find enough free resources that it can use. (12)

Device cannot find enough free resources to use.

Windows cannot verify this device's resources. (13)

Windows cannot verify the device resources.

This device cannot work properly until you restart your computer. (14)

Device cannot work properly until the computer is restarted.

This device is not working properly because there is probably a re-enumeration problem. (15)

Device is not working properly due to a possible re-enumeration problem.

Windows cannot identify all the resources this device uses. (16)

Windows cannot identify all of the resources that the device uses.

This device is asking for an unknown resource type. (17)

Device is requesting an unknown resource type.

Reinstall the drivers for this device. (18)

Device drivers must be reinstalled.

Failure using the VxD loader. (19)

Your registry might be corrupted. (20)

Registry might be corrupted.

System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. (21)

System failure. If changing the device driver is ineffective, see the hardware documentation. Windows is removing the device.

This device is disabled. (22)

Device is disabled.

System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation. (23)

System failure. If changing the device driver is ineffective, see the hardware documentation.

This device is not present, is not working properly, or does not have all its drivers installed. (24)

Device is not present, not working properly, or does not have all of its drivers installed.

Windows is still setting up this device. (25)

Windows is still setting up the device.

Windows is still setting up this device. (26)

Windows is still setting up the device.

This device does not have valid log configuration. (27)

Device does not have valid log configuration.

The drivers for this device are not installed. (28)

Device drivers are not installed.

This device is disabled because the firmware of the device did not give it the required resources. (29)

Device is disabled. The device firmware did not provide the required resources.

This device is using an Interrupt Request (IRQ) resource that another device is using. (30)

Device is using an IRQ resource that another device is using.

This device is not working properly because Windows cannot load the drivers required for this device. (31)

Device is not working properly. Windows cannot load the required device drivers.

ConfigManagerUserConfig

Data type: boolean

Access type: Read-only

Qualifiers: Schema ("Win32")

If True, the device is using a user-defined configuration.

This property is inherited from CIM_LogicalDevice.

CreationClassName

Data type: string

Access type: Read-only

Qualifiers: CIM_Key

Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified.

This property is inherited from CIM_LogicalDevice.

Description

Data type: string

Access type: Read-only

Qualifiers: DisplayName ("Description")

Description of the object.

This property is inherited from CIM_ManagedSystemElement.

DeviceID

Data type: string

Access type: Read-only

Qualifiers: Key, Override ("DeviceId"), MappingStrings ("WMI")

Unique identifier of the logical disk from other devices on the system.

This property is inherited from CIM_LogicalDevice.

For a code example that retrieves this property, see the Remarks section, below.

DriveType

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|FileFunctions|GetDriveType")

Numeric value that corresponds to the type of disk drive this logical disk represents.

Unknown (0)

No Root Directory (1)

Removable Disk (2)

Local Disk (3)

Network Drive (4)

Compact Disc (5)

RAM Disk (6)

ErrorCleared

Data type: boolean

Access type: Read-only

If True, the error reported in LastErrorCode is now cleared.

This property is inherited from CIM_LogicalDevice.

ErrorDescription

Data type: string

Access type: Read-only

More information about the error recorded in LastErrorCode, and information on any corrective actions that may be taken.

This property is inherited from CIM_LogicalDevice.

ErrorMethodology

Data type: string

Access type: Read-only

Type of error detection and correction supported by this storage extent.

This property is inherited from CIM_StorageExtent.

FileSystem

Data type: string

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|File System FunctionsGetVolumeInformation)

File system on the logical disk.

Example: "NTFS"

FreeSpace

Data type: uint64

Access type: Read-only

Qualifiers: units ("bytes")

Space, in bytes, available on the logical disk.

This property is inherited from CIM_LogicalDisk.

For more information about using uint64 values in scripts, see Scripting in WMI.

InstallDate

Data type: datetime

Access type: Read-only

Qualifiers: MappingStrings ("MIF.DMTF|ComponentID|001.5"), DisplayName ("Install Date")

Date and time the object was installed. This property does not require a value to indicate that the object is installed.

This property is inherited from CIM_ManagedSystemElement.

LastErrorCode

Data type: uint32

Access type: Read-only

Last error code reported by the logical device.

This property is inherited from CIM_LogicalDevice.

MaximumComponentLength

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|File System FunctionsGetVolumeInformation)

Maximum length of a filename component supported by the Windows drive. A filename component is that portion of a filename between backslashes. The value can be used to indicate that long names are supported by the specified file system. For example, for a FAT file system supporting long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the NTFS file system.

Example: 255

MediaType

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Device Input and Output Functions|DeviceIoControl")

Type of media currently present in the logical drive. This value will be one of the values of the MEDIA_TYPE enumeration defined in Winioctl.h. The value may not be exact for removable drives if currently there is no media in the drive.

Format is unknown (0)

5 -Inch Floppy Disk (1)

5 1/4-Inch Floppy Disk - 1.2 MB - 512 bytes/sector

3 -Inch Floppy Disk (2)

3 1/2-Inch Floppy Disk - 1.44 MB -512 bytes/sector

3 -Inch Floppy Disk (3)

3 1/2-Inch Floppy Disk - 2.88 MB - 512 bytes/sector

3 -Inch Floppy Disk (4)

3 1/2-Inch Floppy Disk - 20.8 MB - 512 bytes/sector

3 -Inch Floppy Disk (5)

3 1/2-Inch Floppy Disk - 720 KB - 512 bytes/sector

5 -Inch Floppy Disk (6)

5 1/4-Inch Floppy Disk - 360 KB - 512 bytes/sector

5 -Inch Floppy Disk (7)

5 1/4-Inch Floppy Disk - 320 KB - 512 bytes/sector

5 -Inch Floppy Disk (8)

5 1/4-Inch Floppy Disk - 320 KB - 1024 bytes/sector

5 -Inch Floppy Disk (9)

5 1/4-Inch Floppy Disk - 180 KB - 512 bytes/sector

5 -Inch Floppy Disk (10)

5 1/4-Inch Floppy Disk - 160 KB - 512 bytes/sector

Removable media other than floppy (11)

Fixed hard disk media (12)

3 -Inch Floppy Disk (13)

3 1/2-Inch Floppy Disk - 120 MB - 512 bytes/sector

3 -Inch Floppy Disk (14)

3 1/2-Inch Floppy Disk - 640 KB - 512 bytes/sector

5 -Inch Floppy Disk (15)

5 1/4-Inch Floppy Disk - 640 KB - 512 bytes/sector

5 -Inch Floppy Disk (16)

5 1/4-Inch Floppy Disk - 720 KB - 512 bytes/sector

3 -Inch Floppy Disk (17)

3 1/2-Inch Floppy Disk - 1.2 MB - 512 bytes/sector

3 -Inch Floppy Disk (18)

3 1/2-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector

5 -Inch Floppy Disk (19)

5 1/4-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector

3 -Inch Floppy Disk (20)

3 1/2-Inch Floppy Disk - 128 MB - 512 bytes/sector

3 -Inch Floppy Disk (21)

3 1/2-Inch Floppy Disk - 230 MB - 512 bytes/sector

8-Inch Floppy Disk (22)

8-Inch Floppy Disk - 256 KB - 128 bytes/sector

Name

Data type: string

Access type: Read-only

Qualifiers: DisplayName ("Name")

Label by which the object is known. When subclassed, this property can be overridden to be a key property.

This property is inherited from CIM_ManagedSystemElement.

NumberOfBlocks

Data type: uint64

Access type: Read-only

Qualifiers: MappingStrings ("MIB.IETF|HOST-RESOURCES-MIB.hrStorageSize")

Total number of consecutive blocks, each block the size of the value contained in the BlockSize property, which form this storage extent. Total size of the storage extent can be calculated by multiplying the value of the BlockSize property by the value of this property. If the value of BlockSize is 1, this property is the total size of the storage extent.

This property is inherited from CIM_StorageExtent.

For more information about using uint64 values in scripts, see Scripting in WMI.

PNPDeviceID

Data type: string

Access type: Read-only

Qualifiers: Schema ("Win32")

Windows Plug and Play device identifier of the logical device.

This property is inherited from CIM_LogicalDevice.

Example: "*PNP030b"

PowerManagementCapabilities

Data type: uint16 array

Access type: Read-only

Array of the specific power-related capabilities of a logical device.

This property is inherited from CIM_LogicalDevice.

Unknown (0)

Not Supported (1)

Disabled (2)

Enabled (3)

The power management features are currently enabled but the exact feature set is unknown or the information is unavailable.

Power Saving Modes Entered Automatically (4)

The device can change its power state based on usage or other criteria.

Power State Settable (5)

The SetPowerState method is supported. This method is found on the parent CIM_LogicalDevice class and can be implemented. For more information, see Designing Managed Object Format (MOF) Classes.

Power Cycling Supported (6)

The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle).

Timed Power On Supported (7)

Timed Power-On Supported

The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle) and Time set to a specific date and time, or interval, for power-on.

PowerManagementSupported

Data type: boolean

Access type: Read-only

If True, the device can be power-managed (can be put into suspend mode, and so on). This property does not indicate that power management features are currently enabled, only that the logical device is capable of power management.

This property is inherited from CIM_LogicalDevice.

ProviderName

Data type: string

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|Windows Networking Functions|WNetGetConnection")

Network path to the logical device.

Purpose

Data type: string

Access type: Read-only

Free-form string describing the media and its use.

This property is inherited from CIM_StorageExtent.

QuotasDisabled

Data type: boolean

Access type: Read-only

Indicates that quota management is not enabled (TRUE) on this system.

QuotasIncomplete

Data type: boolean

Access type: Read-only

Indicates that the quota management was used but has been disabled (True). Incomplete refers to the information left in the file system after quota management was disabled.

QuotasRebuilding

Data type: boolean

Access type: Read-only

If True, indicates that the file system is in the active process of compiling information and setting the disk up for quota management.

Size

Data type: uint64

Access type: Read-only

Qualifiers: units ("bytes")

Size of the disk drive.

This property is inherited from CIM_LogicalDisk.

For a code example that retrieves this property, see the Remarks section, below.

Status

Data type: string

Access type: Read-only

Qualifiers: MaxLen (10), DisplayName ("Status")

Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states.

This property is inherited from CIM_ManagedSystemElement.

Values include the following:

OK ("OK")

Error ("Error")

Degraded ("Degraded")

Unknown ("Unknown")

Pred Fail ("Pred Fail")

Starting ("Starting")

Stopping ("Stopping")

Service ("Service")

Stressed ("Stressed")

NonRecover ("NonRecover")

No Contact ("No Contact")

Lost Comm ("Lost Comm")

StatusInfo

Data type: uint16

Access type: Read-only

Qualifiers: MappingStrings ("MIF.DMTF|Operational State|003.3")

State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used.

This property is inherited from CIM_LogicalDevice.

Other (1)

Unknown (2)

Enabled (3)

Disabled (4)

Not Applicable (5)

SupportsDiskQuotas

Data type: boolean

Access type: Read-only

If True, this volume supports disk quotas.

SupportsFileBasedCompression

Data type: boolean

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|File System Functions|GetVolumeInformation|FS_FILE_COMPRESSION")

If True, the logical disk partition supports file-based compression, such as is the case with the NTFS file system. This property is False when the Compressed property is True.

SystemCreationClassName

Data type: string

Access type: Read-only

Qualifiers: Propagated ("CIM_System.CreationClassName"), CIM_Key

Value of the scoping computer CreationClassName property.

This property is inherited from CIM_LogicalDevice.

SystemName

Data type: string

Access type: Read-only

Qualifiers: Propagated ("CIM_System.Name"), CIM_Key

Name of the scoping system.

This property is inherited from CIM_LogicalDevice.

VolumeDirty

Data type: boolean

Access type: Read-only

Qualifiers: MappingStrings ("FSCTL_IS_VOLUME_DIRTY")

If True, the disk requires ChkDsk to be run at the next restart. This property is only applicable to those instances of logical disk that represent a physical disk in the machine. It is not applicable to mapped logical drives.

VolumeName

Data type: string

Access type: Read/write

Qualifiers: MappingStrings ("Win32API|File System FunctionsGetVolumeInformation)

Volume name of the logical disk.

Constraints: Maximum 32 characters.

For a code example that retrieves this property, see the Remarks section, below.

VolumeSerialNumber

Data type: string

Access type: Read-only

Qualifiers: MappingStrings ("Win32API|File System FunctionsGetVolumeInformation)

Volume serial number of the logical disk.

Constraints: Maximum 11 characters.

Example: "A8C3-D032"

Remarks

The Win32_LogicalDisk class is derived from CIM_LogicalDisk which derives from CIM_StorageExtent. The CIM_StorageExtent class is derived from CIM_LogicalDevice.

A physical disk drive is the cornerstone of any storage management system. However, after a physical disk drive has been installed, neither users nor system administrators typically deal with the hardware directly. Instead, both users and system administrators interact with the logical drives that have been created on the disk.

A logical drive is a subdivision of a partition that has been assigned its own drive letter. (It is possible to have a partition that has not been assigned a drive letter.) When you talk about drive C or drive D, you are referring to a logical drive rather than to a physical disk drive. Likewise, when you save a document to drive E, you are saving it to the logical drive. Physical disks compose the hardware that makes up a drive, including such components as heads, sectors, and cylinders. Logical drives, by contrast, have properties such as disk space, available disk space, and drive letters.

Note

The Win32_LogicalDisk class can be used only to enumerate the properties of local disk drives. However, you can use the Win32_MappedLogicalDisk class to enumerate the properties of mapped network drives.

Examples

You can find other examples using Win32_LogicalDisk to obtain disk or volume data in the WMI Tasks: Disks and File Systems topic.

Enterprise scripting often involves configuring hardware and software on remote computers; in turn, this requires you to know, in advance, the type of disk drives installed on a computer. For example, a script that installs an application on drive E works only if drive E is a hard disk. If drive E happens to represent a floppy disk or a CD-ROM drive, the script fails. The following code identifies the drives and drive types installed on a computer

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk")
For Each objDisk in colDisks
 Wscript.Echo "DeviceID: "& objDisk.DeviceID 
 Select Case objDisk.DriveType
 Case 1
 Wscript.Echo "No root directory."
 Case 2
 Wscript.Echo "DriveType: Removable drive."
 Case 3
 Wscript.Echo "DriveType: Local hard disk."
 Case 4
 Wscript.Echo "DriveType: Network disk." 
 Case 5
 Wscript.Echo "DriveType: Compact disk." 
 Case 6
 Wscript.Echo "DriveType: RAM disk." 
 Case Else
 Wscript.Echo "Drive type could not be determined."
 End Select
Next

//be sure to References->Add->System.Management to your project
using System.Management;
...
{
   string strComputer = ".";
            
   ManagementScope namespaceScope = new ManagementScope("\\\\" + strComputer + "\\ROOT\\CIMV2");
   ObjectQuery diskQuery = new ObjectQuery("SELECT * FROM Win32_LogicalDisk");
   ManagementObjectSearcher mgmtObjSearcher = new ManagementObjectSearcher(namespaceScope, diskQuery);
   ManagementObjectCollection colDisks = mgmtObjSearcher.Get();

   foreach (ManagementObject objDisk in colDisks)
   {
      Console.WriteLine("Device ID : {0}", objDisk["DeviceID"]);
                
      switch ((uint)(objDisk["DriveType"]))
      {
         case 1: {   Console.WriteLine("No root directory.");
                     break;}
         case 2: {   Console.WriteLine("DriveType: Removable drive."); 
                     break;}
         case 3: {   Console.WriteLine("DriveType: Local hard disk.");
                     break;}
         case 4: {   Console.WriteLine("DriveType: Network disk.");
                     break;}
         case 5: {   Console.WriteLine("DriveType: Compact disk.");
                     break;}
         case 6: {   Console.WriteLine("DriveType: RAM disk.");
                     break;}
         default: {  Console.WriteLine("Drive type could not be determined.");
                     break;}
      }
      //Readline is in here so the user can see the result before the code exists
      Console.ReadLine();
   }
}

The following samples enumerate the free space on all the hard disk drives on a computer.

Const HARD_DISK = 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk WHERE DriveType = " & HARD_DISK & "")
For Each objDisk in colDisks
 Wscript.Echo "Device ID: " & objDisk.DeviceID 
 Wscript.Echo "Free Disk Space: " & objDisk.FreeSpace
Next

//be sure to References->Add->System.Management to your project
using System.Management;
...

const int HARD_DISK = 3;
string strComputer = ".";

ManagementScope namespaceScope = new ManagementScope("\\\\" + strComputer + "\\ROOT\\CIMV2");
ObjectQuery diskQuery = new ObjectQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType = " + HARD_DISK + "");
ManagementObjectSearcher mgmtObjSearcher = new ManagementObjectSearcher(namespaceScope, diskQuery);
ManagementObjectCollection colDisks = mgmtObjSearcher.Get();

foreach (ManagementObject objDisk in colDisks)
{
    Console.WriteLine("Device ID : {0}", objDisk["DeviceID"]);
    Console.WriteLine("Free Disk Space : {0}", objDisk["FreeSpace"]);
    Console.ReadLine();
}

The following code example returns the type of file system (FAT, NTFS, FAT32, and so on) used on each drive in a computer.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMv2")
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
    Wscript.Echo "DeviceID: "& vbTab &  objDisk.DeviceID  
    Wscript.Echo "File System: "& vbTab & objDisk.FileSystem
Next

Get-WMIObject Win32_LogicalDisk | Select DeviceID, FileSystem | Format=Table -AutoSize

The following PowerShell code sample retrieves additional information about the logical local disks.

Write-Host "Drive information for $env:ComputerName"

Get-WmiObject -Class Win32_LogicalDisk |
    Where-Object {$_.DriveType -ne 5} |
    Sort-Object -Property Name | 
    Select-Object Name, VolumeName, FileSystem, Description, VolumeDirty, `
        @{"Label"="DiskSize(GB)";"Expression"={"{0:N}" -f ($_.Size/1GB) -as [float]}}, `
        @{"Label"="FreeSpace(GB)";"Expression"={"{0:N}" -f ($_.FreeSpace/1GB) -as [float]}}, `
        @{"Label"="%Free";"Expression"={"{0:N}" -f ($_.FreeSpace/$_.Size*100) -as [float]}} |
    Format-Table -AutoSize

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
CIMWin32.mof
DLL
CIMWin32.dll

See also

CIM_LogicalDisk

Computer System Hardware Classes

WMI Tasks: Disks and File Systems