Win32_LogicalDisk

Win32 Logical Disk
root/cimv2dynamickey : DeviceID

Represents a data source that resolves to an actual local storage device on a computer system running Windows.

On this page

Main example

List instances

# All instances of Win32_LogicalDisk, with the main properties
Get-CimInstance -ClassName Win32_LogicalDisk |
    Select-Object -Property @(
        'DeviceID'
        'VolumeName'
        'FileSystem'
        @{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
        @{ Name = 'FreeSpaceGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 2) } }
        'DriveType'
    )

Examples

Filter with WQL

# WQL filter evaluated by the provider: DriveType = 3 (Local Disk)
Get-CimInstance -ClassName Win32_LogicalDisk -Filter 'DriveType = 3' |
    Select-Object -Property @(
        'DeviceID'
        'VolumeName'
        'FileSystem'
        @{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
        @{ Name = 'FreeSpaceGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 2) } }
        'DriveType'
    )

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Decode numeric values

# Lookup table for DriveType (values documented by Microsoft)
$driveTypeName = @{
    0 = 'Unknown'
    1 = 'No Root Directory'
    2 = 'Removable Disk'
    3 = 'Local Disk'
    4 = 'Network Drive'
    5 = 'Compact Disc'
    6 = 'RAM Disk'
}
# Lookup table for Access (values documented by Microsoft)
$accessName = @{
    0 = 'Unknown'
    1 = 'Readable'
    2 = 'Writeable'
    3 = 'Read/Write Supported'
    4 = 'Write Once'
}

Get-CimInstance -ClassName Win32_LogicalDisk |
    Select-Object -Property @(
        'DeviceID'
        'VolumeName'
        'FileSystem'
        @{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
        @{ Name = 'FreeSpaceGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 2) } }
        @{ Name = 'DriveType'; Expression = { $driveTypeName[[int]$_.DriveType] } }
        @{ Name = 'Access'; Expression = { $accessName[[int]$_.Access] } }
    )

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    Get-CimInstance -CimSession $cimSession -ClassName Win32_LogicalDisk |
        Select-Object -Property @(
            'DeviceID'
            'VolumeName'
            'FileSystem'
            @{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
            @{ Name = 'FreeSpaceGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 2) } }
            'DriveType'
        )
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_LogicalDisk
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

# Methods of the class
$cimClass.CimClassMethods |
    Select-Object -Property Name, ReturnType

Properties

40 of 40 properties
NameTypeAccessDescription
Accessuint16read

Type of media access available.

Values (5)
ValueLabelDescription
0Unknown
1Readable
2WriteableWritable
3Read/Write Supported
4Write Once
Code
# Value of Access for each instance
# Lookup table for Access (values documented by Microsoft)
$accessName = @{
    0 = 'Unknown'
    1 = 'Readable'
    2 = 'Writeable'
    3 = 'Read/Write Supported'
    4 = 'Write Once'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Access |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'Access'; Expression = { $accessName[[int]$_.Access] } }
    )
Availabilityuint16read

Availability and status of the device.

Values (21)
ValueLabelDescription
1Other
2Unknown
3Running/Full PowerRunning or Full Power
4Warning
5In Test
6Not Applicable
7Power Off
8Off LineOffline
9Off Duty
10Degraded
11Not Installed
12Install Error
13Power Save - UnknownThe device is known to be in a power save mode, but its exact status is unknown.
14Power Save - Low Power ModeThe device is in a power save state, but still functioning, and may exhibit degraded performance.
15Power Save - StandbyThe device is not functioning, but could be brought to full power quickly.
16Power Cycle
17Power Save - WarningThe device is in a warning state, but also in a power save mode.
18PausedThe device is paused.
19Not ReadyThe device is not ready.
20Not ConfiguredThe device is not configured.
21QuiescedThe device is quiet.
Code
# Value of Availability for each instance
# Lookup table for Availability (values documented by Microsoft)
$availabilityName = @{
    1 = 'Other'
    2 = 'Unknown'
    3 = 'Running/Full Power'
    4 = 'Warning'
    5 = 'In Test'
    6 = 'Not Applicable'
    7 = 'Power Off'
    8 = 'Off Line'
    9 = 'Off Duty'
    10 = 'Degraded'
    11 = 'Not Installed'
    12 = 'Install Error'
    13 = 'Power Save - Unknown'
    14 = 'Power Save - Low Power Mode'
    15 = 'Power Save - Standby'
    16 = 'Power Cycle'
    17 = 'Power Save - Warning'
    18 = 'Paused'
    19 = 'Not Ready'
    20 = 'Not Configured'
    21 = 'Quiesced'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Availability |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'Availability'; Expression = { $availabilityName[[int]$_.Availability] } }
    )
BlockSizeuint64read

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.

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

Unit: bytes

Code
# Value of BlockSize for each instance
# BlockSize is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, BlockSize |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'BlockSizeGB'; Expression = { [math]::Round($_.BlockSize / 1GB, 2) } }
    )
Captionstringread

Short description of the object a one-line string.

Code
# Value of Caption for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Caption |
    Select-Object -Property DeviceID, Caption
Compressedbooleanread

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.

Code
# Value of Compressed for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Compressed |
    Select-Object -Property DeviceID, Compressed
ConfigManagerErrorCodeuint32read

Windows Configuration Manager error code.

Values (32)
ValueLabelDescription
0This device is working properly.Device is working properly.
1This device is not configured correctly.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.Driver for this device might be corrupted, or the system may be low on memory or other resources.
4This device is not working properly. One of its drivers or your registry might be corrupted.Device is not working properly. One of its drivers or the registry might be corrupted.
5The driver for this device needs a resource that Windows cannot manage.Driver for the device requires a resource that Windows cannot manage.
6The boot configuration for this device conflicts with other devices.Boot configuration for the device conflicts with other devices.
7Cannot filter.
8The driver loader for the device is missing.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.Device is not working properly. The controlling firmware is incorrectly reporting the resources for the device.
10This device cannot start.Device cannot start.
11This device failed.Device failed.
12This device cannot find enough free resources that it can use.Device cannot find enough free resources to use.
13Windows cannot verify this device's resources.Windows cannot verify the device resources.
14This device cannot work properly until you restart your computer.Device cannot work properly until the computer is restarted.
15This device is not working properly because there is probably a re-enumeration problem.Device is not working properly due to a possible re-enumeration problem.
16Windows cannot identify all the resources this device uses.Windows cannot identify all of the resources that the device uses.
17This device is asking for an unknown resource type.Device is requesting an unknown resource type.
18Reinstall the drivers for this device.Device drivers must be reinstalled.
19Failure using the VxD loader.
20Your registry might be corrupted.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.System failure. If changing the device driver is ineffective, see the hardware documentation. Windows is removing the device.
22This device is disabled.Device is disabled.
23System failure: Try changing the driver for this device. If that doesn't work, see your hardware documentation.System failure. If changing the device driver is ineffective, see the hardware documentation.
24This device is not present, is not working properly, or does not have all its drivers installed.Device is not present, not working properly, or does not have all of its drivers installed.
25Windows is still setting up this device.Windows is still setting up the device.
26Windows is still setting up this device.Windows is still setting up the device.
27This device does not have valid log configuration.Device does not have valid log configuration.
28The drivers for this device are not installed.Device drivers are not installed.
29This device is disabled because the firmware of the device did not give it the required resources.Device is disabled. The device firmware did not provide the required resources.
30This device is using an Interrupt Request (IRQ) resource that another device is using.Device is using an IRQ resource that another device is using.
31This device is not working properly because Windows cannot load the drivers required for this device.Device is not working properly. Windows cannot load the required device drivers.
Code
# Value of ConfigManagerErrorCode for each instance
# Lookup table for ConfigManagerErrorCode (values documented by Microsoft)
$configManagerErrorCodeName = @{
    0 = 'This device is working properly'
    1 = 'This device is not configured correctly'
    2 = 'Windows cannot load the driver for this device'
    3 = 'The driver for this device might be corrupted, or your…'
    4 = 'This device is not working properly'
    5 = 'The driver for this device needs a resource that Windows…'
    6 = 'The boot configuration for this device conflicts with other…'
    7 = 'Cannot filter'
    8 = 'The driver loader for the device is missing'
    9 = 'This device is not working properly because the controlling…'
    10 = 'This device cannot start'
    11 = 'This device failed'
    12 = 'This device cannot find enough free resources that it can use'
    13 = 'Windows cannot verify this device''s resources'
    14 = 'This device cannot work properly until you restart your…'
    15 = 'This device is not working properly because there is…'
    16 = 'Windows cannot identify all the resources this device uses'
    17 = 'This device is asking for an unknown resource type'
    18 = 'Reinstall the drivers for this device'
    19 = 'Failure using the VxD loader'
    20 = 'Your registry might be corrupted'
    21 = 'System failure: Try changing the driver for this device'
    22 = 'This device is disabled'
    23 = 'System failure: Try changing the driver for this device'
    24 = 'This device is not present, is not working properly, or does…'
    25 = 'Windows is still setting up this device'
    26 = 'Windows is still setting up this device'
    27 = 'This device does not have valid log configuration'
    28 = 'The drivers for this device are not installed'
    29 = 'This device is disabled because the firmware of the device…'
    30 = 'This device is using an Interrupt Request (IRQ) resource…'
    31 = 'This device is not working properly because Windows cannot…'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ConfigManagerErrorCode |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'ConfigManagerErrorCode'; Expression = { $configManagerErrorCodeName[[int]$_.ConfigManagerErrorCode] } }
    )
ConfigManagerUserConfigbooleanread

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

Code
# Value of ConfigManagerUserConfig for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ConfigManagerUserConfig |
    Select-Object -Property DeviceID, ConfigManagerUserConfig
CreationClassName keystringread

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.

Code
# Value of CreationClassName for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, CreationClassName |
    Select-Object -Property DeviceID, CreationClassName
Descriptionstringread

Description of the object.

Code
# Value of Description for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Description |
    Select-Object -Property DeviceID, Description
DeviceID keystringread

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

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

Code
# Value of DeviceID for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID |
    Select-Object -Property DeviceID
DriveTypeuint32read

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

Values (7)
ValueLabelDescription
0Unknown
1No Root Directory
2Removable Disk
3Local Disk
4Network Drive
5Compact Disc
6RAM Disk
Code
# Value of DriveType for each instance
# Lookup table for DriveType (values documented by Microsoft)
$driveTypeName = @{
    0 = 'Unknown'
    1 = 'No Root Directory'
    2 = 'Removable Disk'
    3 = 'Local Disk'
    4 = 'Network Drive'
    5 = 'Compact Disc'
    6 = 'RAM Disk'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, DriveType |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'DriveType'; Expression = { $driveTypeName[[int]$_.DriveType] } }
    )
ErrorClearedbooleanread

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

Code
# Value of ErrorCleared for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ErrorCleared |
    Select-Object -Property DeviceID, ErrorCleared
ErrorDescriptionstringread

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

Code
# Value of ErrorDescription for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ErrorDescription |
    Select-Object -Property DeviceID, ErrorDescription
ErrorMethodologystringread

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

Code
# Value of ErrorMethodology for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ErrorMethodology |
    Select-Object -Property DeviceID, ErrorMethodology
FileSystemstringread

File system on the logical disk.

Example: "NTFS"

Code
# Value of FileSystem for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, FileSystem |
    Select-Object -Property DeviceID, FileSystem
FreeSpaceuint64read

Space, in bytes, available on the logical disk.

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

Unit: bytes

Code
# Value of FreeSpace for each instance
# FreeSpace is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, FreeSpace |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'FreeSpaceGB'; Expression = { [math]::Round($_.FreeSpace / 1GB, 2) } }
    )
InstallDatedatetimeread

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

Code
# Value of InstallDate for each instance
# CIM cmdlets already return a DateTime object: no conversion is needed
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, InstallDate |
    Select-Object -Property DeviceID, InstallDate
LastErrorCodeuint32read

Last error code reported by the logical device.

Code
# Value of LastErrorCode for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, LastErrorCode |
    Select-Object -Property DeviceID, LastErrorCode
MaximumComponentLengthuint32read

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

Code
# Value of MaximumComponentLength for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, MaximumComponentLength |
    Select-Object -Property DeviceID, MaximumComponentLength
MediaTypeuint32read

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.

Values (23)
ValueLabelDescription
0Format is unknown
15 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 1.2 MB - 512 bytes/sector
23 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 1.44 MB -512 bytes/sector
33 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 2.88 MB - 512 bytes/sector
43 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 20.8 MB - 512 bytes/sector
53 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 720 KB - 512 bytes/sector
65 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 360 KB - 512 bytes/sector
75 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 320 KB - 512 bytes/sector
85 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 320 KB - 1024 bytes/sector
95 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 180 KB - 512 bytes/sector
105 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 160 KB - 512 bytes/sector
11Removable media other than floppy
12Fixed hard disk media
133 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 120 MB - 512 bytes/sector
143 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 640 KB - 512 bytes/sector
155 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 640 KB - 512 bytes/sector
165 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 720 KB - 512 bytes/sector
173 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 1.2 MB - 512 bytes/sector
183 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector
195 -Inch Floppy Disk5 1/4-Inch Floppy Disk - 1.23 MB - 1024 bytes/sector
203 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 128 MB - 512 bytes/sector
213 -Inch Floppy Disk3 1/2-Inch Floppy Disk - 230 MB - 512 bytes/sector
228-Inch Floppy Disk8-Inch Floppy Disk - 256 KB - 128 bytes/sector
Code
# Value of MediaType for each instance
# Lookup table for MediaType (values documented by Microsoft)
$mediaTypeName = @{
    0 = 'Format is unknown'
    1 = '5 -Inch Floppy Disk'
    2 = '3 -Inch Floppy Disk'
    3 = '3 -Inch Floppy Disk'
    4 = '3 -Inch Floppy Disk'
    5 = '3 -Inch Floppy Disk'
    6 = '5 -Inch Floppy Disk'
    7 = '5 -Inch Floppy Disk'
    8 = '5 -Inch Floppy Disk'
    9 = '5 -Inch Floppy Disk'
    10 = '5 -Inch Floppy Disk'
    11 = 'Removable media other than floppy'
    12 = 'Fixed hard disk media'
    13 = '3 -Inch Floppy Disk'
    14 = '3 -Inch Floppy Disk'
    15 = '5 -Inch Floppy Disk'
    16 = '5 -Inch Floppy Disk'
    17 = '3 -Inch Floppy Disk'
    18 = '3 -Inch Floppy Disk'
    19 = '5 -Inch Floppy Disk'
    20 = '3 -Inch Floppy Disk'
    21 = '3 -Inch Floppy Disk'
    22 = '8-Inch Floppy Disk'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, MediaType |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'MediaType'; Expression = { $mediaTypeName[[int]$_.MediaType] } }
    )
Namestringread

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

Code
# Value of Name for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Name |
    Select-Object -Property DeviceID, Name
NumberOfBlocksuint64read

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.

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

Code
# Value of NumberOfBlocks for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, NumberOfBlocks |
    Select-Object -Property DeviceID, NumberOfBlocks
PNPDeviceIDstringread

Windows Plug and Play device identifier of the logical device.

Example: "*PNP030b"

Code
# Value of PNPDeviceID for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, PNPDeviceID |
    Select-Object -Property DeviceID, PNPDeviceID
PowerManagementCapabilitiesuint16[]read

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

Values (8)
ValueLabelDescription
0Unknown
1Not Supported
2Disabled
3EnabledThe power management features are currently enabled but the exact feature set is unknown or the information is unavailable.
4Power Saving Modes Entered AutomaticallyThe device can change its power state based on usage or other criteria.
5Power State SettableThe 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.
6Power Cycling SupportedThe SetPowerState method can be invoked with the *PowerState* parameter set to 5 (Power Cycle).
7Timed Power On SupportedTimed 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.
Code
# Value of PowerManagementCapabilities for each instance
# Lookup table for PowerManagementCapabilities (values documented by Microsoft)
$powerManagementCapabilitiesName = @{
    0 = 'Unknown'
    1 = 'Not Supported'
    2 = 'Disabled'
    3 = 'Enabled'
    4 = 'Power Saving Modes Entered Automatically'
    5 = 'Power State Settable'
    6 = 'Power Cycling Supported'
    7 = 'Timed Power On Supported'
}
# PowerManagementCapabilities is an array: -ExpandProperty returns its items one by one
Get-CimInstance -ClassName Win32_LogicalDisk -Property PowerManagementCapabilities |
    Select-Object -ExpandProperty PowerManagementCapabilities |
    ForEach-Object -Process { $powerManagementCapabilitiesName[[int]$_] }
PowerManagementSupportedbooleanread

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.

Code
# Value of PowerManagementSupported for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, PowerManagementSupported |
    Select-Object -Property DeviceID, PowerManagementSupported
ProviderNamestringread

Network path to the logical device.

Code
# Value of ProviderName for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, ProviderName |
    Select-Object -Property DeviceID, ProviderName
Purposestringread

Free-form string describing the media and its use.

Code
# Value of Purpose for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Purpose |
    Select-Object -Property DeviceID, Purpose
QuotasDisabledbooleanread

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

Code
# Value of QuotasDisabled for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, QuotasDisabled |
    Select-Object -Property DeviceID, QuotasDisabled
QuotasIncompletebooleanread

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.

Code
# Value of QuotasIncomplete for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, QuotasIncomplete |
    Select-Object -Property DeviceID, QuotasIncomplete
QuotasRebuildingbooleanread

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

Code
# Value of QuotasRebuilding for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, QuotasRebuilding |
    Select-Object -Property DeviceID, QuotasRebuilding
Sizeuint64read

Size of the disk drive.

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

Unit: bytes

Code
# Value of Size for each instance
# Size is expressed in bytes: converted to GB
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Size |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
    )
Statusstringread

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.

Values include the following:

Values (12)
ValueLabelDescription
OKOK
ErrorError
DegradedDegraded
UnknownUnknown
Pred FailPred Fail
StartingStarting
StoppingStopping
ServiceService
StressedStressed
NonRecoverNonRecover
No ContactNo Contact
Lost CommLost Comm
Code
# Value of Status for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, Status |
    Select-Object -Property DeviceID, Status
StatusInfouint16read

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

Values (5)
ValueLabelDescription
1Other
2Unknown
3Enabled
4Disabled
5Not Applicable
Code
# Value of StatusInfo for each instance
# Lookup table for StatusInfo (values documented by Microsoft)
$statusInfoName = @{
    1 = 'Other'
    2 = 'Unknown'
    3 = 'Enabled'
    4 = 'Disabled'
    5 = 'Not Applicable'
}
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, StatusInfo |
    Select-Object -Property @(
        'DeviceID'
        @{ Name = 'StatusInfo'; Expression = { $statusInfoName[[int]$_.StatusInfo] } }
    )
SupportsDiskQuotasbooleanread

If True, this volume supports disk quotas.

Code
# Value of SupportsDiskQuotas for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, SupportsDiskQuotas |
    Select-Object -Property DeviceID, SupportsDiskQuotas
SupportsFileBasedCompressionbooleanread

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.

Code
# Value of SupportsFileBasedCompression for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, SupportsFileBasedCompression |
    Select-Object -Property DeviceID, SupportsFileBasedCompression
SystemCreationClassName keystringread

Value of the scoping computer CreationClassName property.

Code
# Value of SystemCreationClassName for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, SystemCreationClassName |
    Select-Object -Property DeviceID, SystemCreationClassName
SystemName keystringread

Name of the scoping system.

Code
# Value of SystemName for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, SystemName |
    Select-Object -Property DeviceID, SystemName
VolumeDirtybooleanread

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.

Code
# Value of VolumeDirty for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, VolumeDirty |
    Select-Object -Property DeviceID, VolumeDirty
VolumeNamestringread/write

Volume name of the logical disk.

Constraints: Maximum 32 characters.

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

Code
# Value of VolumeName for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, VolumeName |
    Select-Object -Property DeviceID, VolumeName

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes VolumeName on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$setParameters = @{
    InputObject = $instance
    Property    = @{ VolumeName = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
VolumeSerialNumberstringread

Volume serial number of the logical disk.

Constraints: Maximum 11 characters.

Example: "A8C3-D032"

Code
# Value of VolumeSerialNumber for each instance
Get-CimInstance -ClassName Win32_LogicalDisk -Property DeviceID, VolumeSerialNumber |
    Select-Object -Property DeviceID, VolumeSerialNumber

Methods

Chkdsk #

Invokes the Chkdsk operation on the disk.

uint32 Chkdsk(
    [in] boolean FixErrors,
    [in] boolean VigorousIndexCheck,
    [in] boolean SkipFolderCycle,
    [in] boolean ForceDismount,
    [in] boolean RecoverBadSectors,
    [in] boolean OKToRunAtBootUp
);

Parameters

ParameterTypeDirectionDescription
FixErrorsbooleanin

Indicates what should be done to errors found on the disk. If true, then errors are fixed. The default is false.

VigorousIndexCheckbooleanin

If true, a less vigorous check of index entries should be performed. The default is false.

SkipFolderCyclebooleanin

If true, the folder cycle checking should be skipped. The default is true.

ForceDismountbooleanin

If true, the drive should be forced to dismount before checking. The default is false.

RecoverBadSectorsbooleanin

If true, the bad sectors should be located and the readable information should be recovered from these sectors. The default is false.

OKToRunAtBootUpbooleanin

If true, the chkdsk operation should be performed at next boot up time, in case the operation could not be performed because the disk is locked at time this method is called. The default is false.

Return values

ValueLabelDescription
0Success - Chkdsk completed
1Success - Locked and chkdsk scheduled on reboot
2Failure - Unknown file system
3Failure - Unknown error
4Failure - Unsupported File System

Call the Chkdsk method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'Chkdsk'
    Arguments   = @{
        FixErrors          = $false
        VigorousIndexCheck = $false
        SkipFolderCycle    = $false
        ForceDismount      = $false
        RecoverBadSectors  = $false
        OKToRunAtBootUp    = $false
    }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success - Chkdsk completed'
        1 = 'Success - Locked and chkdsk scheduled on reboot'
        2 = 'Failure - Unknown file system'
        3 = 'Failure - Unknown error'
        4 = 'Failure - Unsupported File System'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

ExcludeFromAutochk #

Excludes disks from the Chkdsk operation to be run at the next restart.

uint32 ExcludeFromAutochk([in] string[] LogicalDisk);

Parameters

ParameterTypeDirectionDescription
LogicalDiskstring[]in

List of drives that should be excluded from autochk at the next reboot. The string syntax consists of the drive letter followed by a colon for the logical disk.

Example: "C:"

Return values

ValueLabelDescription
0Success
1Error - Remote Drive
2Error - Removable Drive
3Error - Drive Not Root Directory
4Error - Unknown Drive

Call the ExcludeFromAutochk method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'ExcludeFromAutochk'
    Arguments   = @{ LogicalDisk = @('Example') }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'Success'
        1 = 'Error - Remote Drive'
        2 = 'Error - Removable Drive'
        3 = 'Error - Drive Not Root Directory'
        4 = 'Error - Unknown Drive'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

ScheduleAutoChk #

Schedules Chkdsk to be run at the next restart if the dirty bit has been set.

uint32 ScheduleAutoChk([in] string[] LogicalDisk);

Parameters

ParameterTypeDirectionDescription
LogicalDiskstring[]in

Specifies the list of drives to schedule for Autochk at the next reboot. The string syntax consists of the drive letter followed by a colon for the logical disk, for example: "C:"

Note: Always check the validity of the drive letters in the *LogicalDisk* array when the data comes from an unknown source, or a source that you do not trust.

Return values

ValueLabelDescription
0No Error
1Error - Remote Drive
2Error - Removable Drive
3Error - Drive Not Root Directory
4Error - Unknown Drive

Call the ScheduleAutoChk method

review before running
# Warning: this method can change the system. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID = 'C:'"
$methodParameters = @{
    InputObject = $instance
    MethodName  = 'ScheduleAutoChk'
    Arguments   = @{ LogicalDisk = @('Example') }
    WhatIf      = $true  # Remove this line to actually run the method
}
$result = Invoke-CimMethod @methodParameters

# With -WhatIf nothing runs and no result is returned
if ($result) {
    $returnValueName = @{
        0 = 'No Error'
        1 = 'Error - Remote Drive'
        2 = 'Error - Removable Drive'
        3 = 'Error - Drive Not Root Directory'
        4 = 'Error - Unknown Drive'
    }
    $returnValueName[[int]$result.ReturnValue]
}

This method can change the system. The -WhatIf parameter shows the operation without running it: remove it only after checking.

Declared but not implemented methods: Reset, SetPowerState.

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.

Inheritance

Superclass chain

  1. CIM_ManagedSystemElement
  2. CIM_LogicalElement
  3. CIM_LogicalDevice
  4. CIM_StorageExtent
  5. CIM_LogicalDisk
  6. Win32_LogicalDisk

Known subclasses

No known subclass.

Requirements

Namespace
root/cimv2
Minimum client
Windows Vista
Minimum server
Windows Server 2008
Provider
CIMWin32
MOF file
CIMWin32.mof
DLL
CIMWin32.dll
Class qualifiers

Dynamic Provider("CIMWin32") SupportsUpdate UUID("{8502C4B7-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.