Click to Rate and Give Feedback
MSDN
MSDN Library
WMI Reference
WMI Classes
Win32 Classes
Win32_Volume
Win32_Volume Class

The Win32_Volume class represents an area of storage on a hard disk. The class returns local volumes that are formatted, unformatted, mounted, or offline. A volume is formatted by using a file system, such as FAT or NTFS, and might have a drive letter assigned to it. One hard disk can have multiple volumes, and volumes can span multiple physical disks. The Win32_Volume class does not support disk drive management.

Windows XP and earlier:  This class is not available.

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

Syntax

class Win32_Volume : CIM_StorageVolume
{
  uint16   Access;
  uint16   Availability;
  uint64   BlockSize;
  string   Caption;
  uint32   ConfigManagerErrorCode;
  boolean  ConfigManagerUserConfig;
  string   CreationClassName;
  string   Description;
  boolean  ErrorCleared;
  string   ErrorDescription;
  string   ErrorMethodology;
  datetime InstallDate;
  uint32   LastErrorCode;
  string   Name;
  uint64   NumberOfBlocks;
  string   PNPDeviceID;
  uint16[] PowerManagementCapabilities;
  boolean  PowerManagementSupported;
  string   Purpose;
  string   Status;
  uint16   StatusInfo;
  string   SystemCreationClassName;
  string   SystemName;
  string   DeviceID;
  uint64   Capacity;
  boolean  Compressed;
  string   DriveLetter;
  uint32   DriveType;
  string   FileSystem;
  uint64   FreeSpace;
  boolean  IndexingEnabled;
  boolean  DirtyBitSet;
  string   Label;
  uint32   MaximumFileNameLength;
  boolean  Automount;
  boolean  QuotasEnabled;
  boolean  QuotasIncomplete;
  boolean  QuotasRebuilding;
  uint32   SerialNumber;
  boolean  SupportsDiskQuotas;
  boolean  SupportsFileBasedCompression;
};

Methods

The Win32_Volume class defines the following methods.

MethodDescription

AddMountPoint

Adds a mount point directory for the volume.

Chkdsk

Invokes the Chkdsk operation on the volume.

ExcludeFromAutoChk

Excludes volumes from the Chkdsk operation to be run at the next reboot.

Format

Formats the volume.

Defrag

Defragments the volume.

DefragAnalysis

Generates a fragmentation analysis for the volume.

Dismount

Dismounts a volume from the file system.

Mount

Mounts a volume to the file system.

ScheduleAutoChk

Schedules Chkdsk to be run at the next reboot if the dirty bit of the volume is set.

 

Properties

The Win32_Volume class defines the following properties.

Access
Data type: uint16
Access type: Read-only

Describes whether the media is readable.

ValueDescription
0Unknown media.
1The media is readable.
2The media is writable.
3The media is readable and writable.
4"Write once" media.

 

Automount
Data type: boolean
Access type: Read-only

If true, the volume is mounted to the file system automatically when the first I/O is issued. If false, the volume is not mounted until explicitly mounted by using the Mount method, or by adding a drive letter or mount point.

Availability
Data type: uint16
Access type: Read-only

Describes the availability and status of the device.

ValueDescription
1Other
2Unknown
3Running orFull Power
4Warning
5In Test
6Not Applicable
7Power Off
8Offline
9Off Duty
10Degraded
11Not Installed
12Install Error
13Power Save - Unknown
14Power Save - Low Power Mode
15Power Save - Standby
16Power Cycle
17Power Save - Warning
18Paused
19Not Ready
20Not Configured
21Quiesced

 

BlockSize
Data type: uint64
Access type: Read-only

Size in bytes of the blocks in this storage extent. If there is a variable block size, then the maximum block size in bytes is specified. If the block size is unknown or if a block concept is not valid (for example, for Aggregate Extents, Memory, or LogicalDisks), the value is 1 (one).

Capacity
Data type: uint64
Access type: Read-only

Size of the volume in bytes.

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

Caption
Data type: string
Access type: Read-only

A short description (one-line string) of the area of storage.

Compressed
Data type: boolean
Access type: Read-only

If true, the volume exists as one compressed entity, such as a DoubleSpace volume. If file-based compression is supported, such as the NTFS file system, this property is false.

ConfigManagerErrorCode
Data type: uint32
Access type: Read-only

Indicates the Win32 Configuration Manager error code.

ValueDescription
0This device is working properly.
1This device is not configured correctly.
2Windows cannot load the driver for this device.
3The driver for this device might be corrupted, or your system may be running low on memory or other resources.
4This device is not working properly. One of its drivers or your registry might be corrupted.
5The driver for this device needs a resource that Windows cannot manage.
6The boot configuration for this device conflicts with other devices.
7Cannot filter.
8The driver loader for the device is missing.
9This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.
10This device cannot start.
11This device failed.
12This device cannot find enough free resources that it can use.
13Windows cannot verify this device's resources.
14This device cannot work properly until you restart your computer.
15This device is not working properly because there is probably a re-enumeration problem.
16Windows cannot identify all the resources this device uses.
17This device is asking for an unknown resource type.
18Reinstall the drivers for this device.
19Failure using the VxD loader.
20Your registry might be corrupted.
21System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.
22This device is disabled.
23System failure. Try changing the driver for this device. If that does not work, see your hardware documentation.
24This device is not present, is not working properly, or does not have all of its drivers installed.
25Windows is still setting up this device.
26Windows is still setting up this device.
27This device does not have a valid log configuration.
28The drivers for this device are not installed.
29This device is disabled because the firmware of the device did not give it the required resources.
30This device is using an Interrupt Request resource that another device is using.
31This device is not working properly because Windows cannot load the drivers required for this device.

 

ConfigManagerUserConfig
Data type: boolean
Access type: Read-only

True, if the device is using a user-defined configuration, otherwise False.

CreationClassName
Data type: string
Access type: Read-only

Indicates the name of the class or the subclass used in the creation of an instance of this class. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.

Description
Data type: string
Access type: Read-only

A description of the object.

DeviceID
Data type: string
Access type: Read-only

Unique identifier for the volume on this system.

DirtyBitSet
Data type: boolean
Access type: Read-only

If true, the Chkdsk method is automatically run by the system at the next restart.

DriveLetter
Data type: string
Access type: Read/write

Drive letter assigned to a volume. This property is NULL for volumes without drive letters.

DriveType
Data type: uint32
Access type: Read-only

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

The values are:

ValueMeaning
0

Unknown

1

No Root Directory

2

Removable Disk

3

Local Disk

4

Network Drive

5

Compact Disk

6

RAM Disk

 

ErrorCleared
Data type: boolean
Access type: Read-only

True, if the error reported in the LastErrorCode property is cleared, otherwise False.

ErrorDescription
Data type: string
Access type: Read-only

Supplies more information about the error recorded in the LastErrorCode property and information on any corrective actions that may be taken.

ErrorMethodology
Data type: string
Access type: Read-only

Describes the type of error detection and correction supported by this storage extent.

FileSystem
Data type: string
Access type: Read-only

File system on the logical disk.

Example: NTFS

FreeSpace
Data type: uint64
Access type: Read-only

Number of bytes of available space on the volume.

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

IndexingEnabled
Data type: boolean
Access type: Read/write

If true, context indexing is enabled.

InstallDate
Data type: datetime
Access type: Read-only

Indicates when the object was installed. A lack of a value does not indicate that the object is not installed.

Label
Data type: string
Access type: Read/write

Volume name of the logical disk. This property is null for volumes without a label. For FAT and FAT32 systems, the maximum length is 11 characters. For NTFS file systems, the maximum length is 32 characters.

LastErrorCode
Data type: uint32
Access type: Read-only

Captures the last error code reported by the logical device.

MaximumFileNameLength
Data type: uint32
Access type: Read-only

Maximum length, in characters, of a filename component supported by a Windows drive. A filename component is the portion of a filename between backslashes. This value can be used to indicate that long names are supported by the file system. For example, for a FAT file system that supports long names, the property stores the value 255—not the previous 8.3 indicator. Long names can be supported on systems that use the NTFS file system.

Example: 255

Name
Data type: string
Access type: Read-only

Defines the label by which the object is known. When subclassed, the Name property can be overridden to be a Key property.

NumberOfBlocks
Data type: uint64
Access type: Read-only

Total number of consecutive blocks (each block is the size of the value contained in the BlockSize property) that form this storage extent. The 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.

PNPDeviceID
Data type: string
Access type: Read-only

Indicates the Win32 Plug and Play device ID of the logical device. Example: *PNP030b.

PowerManagementCapabilities
Data type: uint16[]
Access type: Read-only

Indicates the specific power-related capabilities of the logical device.

ValueDescription
0Unknown
1Not Supported
2Disabled
3Enabled
4Power Saving Modes Entered Automatically
5Power State Settable
6Power Cycling Supported
7Timed Power-On Supported

 

PowerManagementSupported
Data type: boolean
Access type: Read-only

True, if the device can be power managed (put into a power save state), otherwise False. This boolean does not indicate that power management features are currently enabled, or if enabled, what features are supported. Refer to the PowerManagementCapabilities array for this information. If this boolean is false, the integer value 1, for the string, "Not Supported", should be the only entry in the PowerManagementCapabilities array.

Purpose
Data type: string
Access type: Read-only

Describes the media and its use.

QuotasEnabled
Data type: boolean
Access type: Read-only

If true, quota management is enabled for this volume.

QuotasIncomplete
Data type: boolean
Access type: Read-only

If true, quota management was used but is disabled. Incomplete refers to the information left in the file system after quota management is disabled.

QuotasRebuilding
Data type: boolean
Access type: Read-only

If true, the file system is in the process of compiling information and setting the disk up for quota management.

SerialNumber
Data type: uint32
Access type: Read-only

Serial number of the volume.

Example: A8C3D032

Status
Data type: string
Access type: Read-only

Indicates the current status of the object. Various operational and nonoperational statuses are defined. Operational statuses are "OK", "Degraded" and "Pred Fail". "Pred Fail" indicates that an element may be functioning properly but predicting a failure in the near future. Nonoperational statuses can also be specified. These are "Error", "Starting", "Stopping", and "Service".

StatusInfo
Data type: uint16
Access type: Read-only

Indicates the state of the logical device.

ValueDescription
1Other
2Unknown
3Enabled
4Disabled
5Not Applicable

 

SupportsDiskQuotas
Data type: boolean
Access type: Read-only

If true, the volume supports disk quotas.

SupportsFileBasedCompression
Data type: boolean
Access type: Read-only

If true, the volume supports file-based compression—like the NTFS file system.

SystemCreationClassName
Data type: string
Access type: Read-only

Indicates the system's creation class name.

SystemName
Data type: string
Access type: Read-only

Indicates the system's name.

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported clientNone supported
Minimum supported serverWindows Server 2003
MOFVds.mof
DLLVdswmi.dll
Namespace\root\cimv2

See Also

Storage Volume Provider
Win32_VolumeQuota
Win32_VolumeUserQuota
Win32_DefragAnalysis
Win32_MountPoint

Send comments about this topic to Microsoft

Build date: 11/3/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Win32_Volume - sample using PowerShell      Thomas Lee   |   Edit   |   Show History
# wmi-volume.ps1
# Displays volumes on the local system
# NB: does not work on XP systems - the class not supported.
# thomas lee - tfl@psp.co.uk
 
# get volumes on this sytstem
$volumes = get-wmiobject Win32_Volume
 
# display volume info
# There are {0} volumes on this system, as follows: " -f ($volumes.length)
# Iterate through volumes and display information
foreach ($vol in $volumes) {
"Volume: {0}" -f ++$i
"============================="
"Access                       : {0}" -f $vol.Access
"Automount : {0}" -f $vol.Automount
"Availability : {0}" -f $vol.Availability
"BlockSize : {0}" -f $vol.BlockSize
"BootVolume : {0}" -f $vol.BootVolume
"Capacity : {0}" -f $vol.Capacity
"Caption : {0}" -f $vol.Caption
"Compressed : {0}" -f $vol.Compressed
"ConfigManagerErrorCode : {0}" -f $vol.ConfigManagerErrorCode
"ConfigManagerUserConfig : {0}" -f $vol.ConfigManagerUserConfig
"CreationClassName : {0}" -f $vol.CreationClassName
"Description : {0}" -f $vol.Description
"DeviceID : {0}" -f $vol.DeviceID
"DirtyBitSet : {0}" -f $vol.DirtyBitSet
"DriveLetter : {0}" -f $vol.DriveLetter
"DriveType : {0}" -f $vol.DriveType
"ErrorCleared : {0}" -f $vol.ErrorCleared
"ErrorDescription : {0}" -f $vol.ErrorDescription
"ErrorMethodology : {0}" -f $vol.ErrorMethodology
"FileSystem : {0}" -f $vol.FileSystem
"FreeSpace : {0}" -f $vol.FreeSpace
"IndexingEnabled : {0}" -f $vol.IndexingEnabled
"InstallDate : {0}" -f $vol.InstallDate
"Label : {0}" -f $vol.Label
"LastErrorCode : {0}" -f $vol.LastErrorCode
"MaximumFileNameLength : {0}" -f $vol.MaximumFileNameLength
"Name : {0}" -f $vol.Name
"NumberOfBlocks : {0}" -f $vol.NumberOfBlocks
"PageFilePresent : {0}" -f $vol.PageFilePresent
"PNPDeviceID : {0}" -f $vol.PNPDeviceID
"PowerManagementCapabilities : {0}" -f $vol.PowerManagementCapabilities
"PowerManagementSupported : {0}" -f $vol.PowerManagementSupported
"Purpose : {0}" -f $vol.Purpose
"QuotasEnabled : {0}" -f $vol.QuotasEnabled
"QuotasIncomplete : {0}" -f $vol.QuotasIncomplete
"QuotasRebuilding : {0}" -f $vol.QuotasRebuilding
"SerialNumber : {0}" -f $vol.SerialNumber
"Status : {0}" -f $vol.Status
"StatusInfo : {0}" -f $vol.StatusInfo
"SupportsDiskQuotas : {0}" -f $vol.SupportsDiskQuotas
"SupportsFileBasedCompression : {0}" -f $vol.SupportsFileBasedCompression
"SystemCreationClassName : {0}" -f $vol.SystemCreationClassName
"SystemName : {0}" -f $vol.SystemName
"SystemVolume : {0}" -f $vol.SystemVolume
""
}
  

Above Sample - output      Thomas Lee   |   Edit   |   Show History

The above script when run on a Longhorn B3 server returns the following output:

PS C:\Users\Administrator> .\wmi-volume.ps1
Volume: 1
=============================
Access :
Automount : True
Availability :
BlockSize : 4096
BootVolume : True
Capacity : 68716326912
Caption : C:\
Compressed : False
ConfigManagerErrorCode :
ConfigManagerUserConfig :
CreationClassName :
Description :
DeviceID : \\?\Volume{8bc8baa1-f4ae-11db-b352-806e6f6e6963}\
DirtyBitSet : False
DriveLetter : C:
DriveType : 3
ErrorCleared :
ErrorDescription :
ErrorMethodology :
FileSystem : NTFS
FreeSpace : 59915177984
IndexingEnabled : True
InstallDate :
Label :
LastErrorCode :
MaximumFileNameLength : 255
Name : C:\
NumberOfBlocks :
PageFilePresent : True
PNPDeviceID :
PowerManagementCapabilities :
PowerManagementSupported :
Purpose :
QuotasEnabled : False
QuotasIncomplete : False
QuotasRebuilding : False
SerialNumber : 3769706593
Status :
StatusInfo :
SupportsDiskQuotas : True
SupportsFileBasedCompression : True
SystemCreationClassName :
SystemName : LHS1
SystemVolume : True

2nd volume outout - now shown.

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker