Поделиться через


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;
  boolean  Automount;
  uint16   Availability;
  uint64   BlockSize;
  uint64   Capacity;
  string   Caption;
  boolean  Compressed;
  uint32   ConfigManagerErrorCode;
  boolean  ConfigManagerUserConfig;
  string   CreationClassName;
  string   Description;
  string   DeviceID;
  boolean  DirtyBitSet;
  string   DriveLetter;
  uint32   DriveType;
  boolean  ErrorCleared;
  string   ErrorDescription;
  string   ErrorMethodology;
  string   FileSystem;
  uint64   FreeSpace;
  boolean  IndexingEnabled;
  datetime InstallDate;
  string   Label;
  uint32   LastErrorCode;
  uint32   MaximumFileNameLength;
  string   Name;
  uint64   NumberOfBlocks;
  string   PNPDeviceID;
  uint16[] PowerManagementCapabilities;
  boolean  PowerManagementSupported;
  string   Purpose;
  boolean  QuotasEnabled;
  boolean  QuotasIncomplete;
  boolean  QuotasRebuilding;
  string   Status;
  uint16   StatusInfo;
  string   SystemCreationClassName;
  string   SystemName;
  uint32   SerialNumber;
  boolean  SupportsDiskQuotas;
  boolean  SupportsFileBasedCompression;
};

Members

The Win32_Volume class has these types of members:

Methods

The Win32_Volume class has these methods.

Method Description
AddMountPoint Adds a mount point directory for the volume.
Chkdsk Invokes the Chkdsk operation on the volume.
Defrag Defragments the volume.
DefragAnalysis Generates a fragmentation analysis for the volume.
Dismount Dismounts a volume from the file system.
ExcludeFromAutoChk Excludes volumes from the Chkdsk operation to be run at the next reboot.
Format Formats the volume.
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 has these properties.

Access

Data type: uint16

Access type: Read-only

Describes whether the media is readable. This property is inherited from CIM_StorageExtent. This can be one of the following values.

Value Meaning
0 (0x0)
Unknown media.
1 (0x1)
The media is readable.
2 (0x2)
The media is writable.
3 (0x3)
The media is readable and writable.
4 (0x4)
"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. Inherited from CIM_LogicalDevice. This can be one of the following values.

Value Meaning
1 (0x1)
Other
2 (0x2)
Unknown
3 (0x3)
Running or Full Power
4 (0x4)
Warning
5 (0x5)
In Test
6 (0x6)
Not Applicable
7 (0x7)
Power Off
8 (0x8)
Offline
9 (0x9)
Off Duty
10 (0xA)
Degraded
11 (0xB)
Not Installed
12 (0xC)
Install Error
13 (0xD)
Power Save - Unknown
The device is known to be in a power save mode, but its exact status is unknown.
14 (0xE)
Power Save - Low Power Mode
The device is in a power save state, but still functioning, and may exhibit degraded performance.
15 (0xF)
Power Save - Standby
The device is not functioning, but could be brought to full power quickly.
16 (0x10)
Power Cycle
17 (0x11)
Power Save - Warning
The device is in a warning state, but also in a power save mode.
18 (0x12)
Paused
19 (0x13)
Not Ready
20 (0x14)
Not Configured
21 (0x15)
Quiesced

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). his property is inherited from CIM_StorageExtent.

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

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 of the area of storage. This property is inherited from CIM_ManagedSystemElement.

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. This can be one of the following values.

Value Meaning
0 (0x0)
This device is working properly.
1 (0x1)
This device is not configured correctly.
2 (0x2)
Windows cannot load the driver for this device.
3 (0x3)
The driver for this device might be corrupted, or your system may be running low on memory or other resources.
4 (0x4)
This device is not working properly. One of its drivers or your registry might be corrupted.
5 (0x5)
The driver for this device needs a resource that Windows cannot manage.
6 (0x6)
The boot configuration for this device conflicts with other devices.
7 (0x7)
Cannot filter.
8 (0x8)
The driver loader for the device is missing.
9 (0x9)
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.
10 (0xA)
This device cannot start.
11 (0xB)
This device failed.
12 (0xC)
This device cannot find enough free resources that it can use.
13 (0xD)
Windows cannot verify this device's resources.
14 (0xE)
This device cannot work properly until you restart your computer.
15 (0xF)
This device is not working properly because there is probably a re-enumeration problem.
16 (0x10)
Windows cannot identify all the resources this device uses.
17 (0x11)
This device is asking for an unknown resource type.
18 (0x12)
Reinstall the drivers for this device.
19 (0x13)
Failure using the VxD loader.
20 (0x14)
Your registry might be corrupted.
21 (0x15)
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.
22 (0x16)
This device is disabled.
23 (0x17)
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation.
24 (0x18)
This device is not present, is not working properly, or does not have all of its drivers installed.
25 (0x19)
Windows is still setting up this device.
26 (0x1A)
Windows is still setting up this device.
27 (0x1B)
This device does not have a valid log configuration.
28 (0x1C)
The drivers for this device are not installed.
29 (0x1D)
This device is disabled because the firmware of the device did not give it the required resources.
30 (0x1E)
This device is using an Interrupt Request resource that another device is using.
31 (0x1F)
This device is not working properly because Windows cannot load the drivers required for this device.

ConfigManagerUserConfig

Data type: boolean

Access type: Read-only

If True, the device is using a user-defined configuration. Otherwise, False. This property is inherited from CIM_LogicalDevice.

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. This property is inherited from CIM_LogicalDevice.

Description

Data type: string

Access type: Read-only

Qualifiers: Key

A description of the object. This property is inherited from CIM_ManagedSystemElement

DeviceID

Data type: string

Access type: Read-only

Unique identifier for the volume on this system. This property is inherited from CIM_LogicalDevice.

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:

Value Meaning
0 (0x0)
Unknown
1 (0x1)
No Root Directory
2 (0x2)
Removable Disk
3 (0x3)
Local Disk
4 (0x4)
Network Drive
5 (0x5)
Compact Disk
6 (0x6)
RAM Disk

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

File system on the logical disk.

Example: NTFS

FreeSpace

Data type: uint64

Access type: Read-only

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.

IndexingEnabled

Data type: boolean

Access type: Read/write

If true, context indexing is enabled.

InstallDate

Data type: datetime

Access type: Read-only

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.

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

Last error code reported by the logical device. This property is inherited from CIM_LogicalDevice.

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

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

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

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. This can be one of the following values.

Value Meaning
0 (0x0)
Unknown
1 (0x1)
Not Supported
2 (0x2)
Disabled
3 (0x3)
Enabled
The power management features are currently enabled but the exact feature set is unknown or the information is unavailable.
4 (0x4)
Power Saving Modes Entered Automatically
The device can change its power state based on usage or other criteria.
5 (0x5)
Power State Settable
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.
6 (0x6)
Power Cycling Supported
The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle).
7 (0x7)
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

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. This property is inherited from CIM_LogicalDevice.

Purpose

Data type: string

Access type: Read-only

Describes the media and its use. This property is inherited from CIM_StorageExtent.

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

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.

The values are:

"OK"

"Error"

"Degraded"

"Unknown"

"Pred Fail"

"Starting"

"Stopping"

"Service"

"Stressed"

"NonRecover"

"No Contact"

"Lost Comm"

StatusInfo

Data type: uint16

Access type: Read-only

Indicates the state of the logical device. This can be one of the following values.

Value Meaning
1 (0x1)
Other
2 (0x2)
Unknown
3 (0x3)
Enabled
4 (0x4)
Disabled
5 (0x5)
Not 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 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

Indicates the system's creation class name.

SystemName

Data type: string

Access type: Read-only

Indicates the system's name.

Examples

The Two WMI Functions PowerShell example in the TechNet Gallery use Win32_Volume to recreate the Windows 8 get-Volume cmdlet.

The following PowerShell sample retrieves the allocation size of the drives on the target system.

$wql = "SELECT BlockSize,DriveLetter,Label FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' | Select-Object DriveLetter,Label,BlockSize | Format-Table -AutoSize

The following PowerShell sample displays information on the volumes on the local system.

$volumes = get-wmiobject Win32_Volume
foreach ($vol in $volumes) {
    "Volume: {0}" -f ++$i
    "============================="
    $vol | Format-List 
}

Requirements

Minimum supported client
None supported
Minimum supported server
Windows Server 2003
Namespace
Root\CIMV2
MOF
Vds.mof
DLL
Vdswmi.dll

See also

Storage Volume Provider

Win32_VolumeQuota

Win32_VolumeUserQuota

Win32_DefragAnalysis

Win32_MountPoint