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.
Methods
Win32_Volume has 9 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. |
Learn more about Invoke-CimMethod
and how to invoke commands. Click any of the methods listed above to learn more about their purpose, parameters, and return value.
Properties
Win32_Volume returns 41 properties:
'Access','Automount','Availability','BlockSize','Capacity','Caption','Compressed',
'ConfigManagerErrorCode','ConfigManagerUserConfig','CreationClassName','Description','DeviceID','DirtyBitSet',
'DriveLetter','DriveType','ErrorCleared','ErrorDescription','ErrorMethodology','FileSystem',
'FreeSpace','IndexingEnabled','InstallDate','Label','LastErrorCode','MaximumFileNameLength',
'Name','NumberOfBlocks','PNPDeviceID','PowerManagementCapabilities',
'PowerManagementSupported','Purpose','QuotasEnabled','QuotasIncomplete','QuotasRebuilding','SerialNumber',
'Status','StatusInfo','SupportsDiskQuotas','SupportsFileBasedCompression',
'SystemCreationClassName','SystemName'
Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:
Get-CimInstance -ClassName Win32_Volume -Property *
Most WMI classes return one or more instances.
When
Get-CimInstance
returns no result, then apparently no instances of class Win32_Volume exist. This is normal behavior.Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).
Access
Access returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Access_map = @{
Unknown media. = '0 (0x0)'
The media is readable. = '1 (0x1)'
The media is writable. = '2 (0x2)'
The media is readable and writable. = '3 (0x3)'
"Write once" media. = '4 (0x4)'
}
Use a switch statement
switch([int]$value)
{
Unknown media. {'0 (0x0)'}
The media is readable. {'1 (0x1)'}
The media is writable. {'2 (0x2)'}
The media is readable and writable. {'3 (0x3)'}
"Write once" media. {'4 (0x4)'}
default {"$value"}
}
Use Enum structure
Enum EnumAccess
{
_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.
}
Examples
Use $Access_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Access" to friendly text
Note: to use other properties than "Access", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Access"
# to translate other properties, use their translation table instead
$Access_map = @{
Unknown media. = '0 (0x0)'
The media is readable. = '1 (0x1)'
The media is writable. = '2 (0x2)'
The media is readable and writable. = '3 (0x3)'
"Write once" media. = '4 (0x4)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Access", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Access = @{
Name = 'Access'
Expression = {
# property is an array, so process all values
$value = $_.Access
$Access_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Access". The latter
# is defined by the hashtable in $Access:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $Access
# ...or dump content of property Access:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $Access |
Select-Object -ExpandProperty Access
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Access_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$Access_map = @{
Unknown media. = '0 (0x0)'
The media is readable. = '1 (0x1)'
The media is writable. = '2 (0x2)'
The media is readable and writable. = '3 (0x3)'
"Write once" media. = '4 (0x4)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Access
# translate raw value to friendly text:
$friendlyName = $Access_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Access" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Access", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Access", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Access = @{
Name = 'Access'
Expression = {
# property is an array, so process all values
$value = $_.Access
switch([int]$value)
{
Unknown media. {'0 (0x0)'}
The media is readable. {'1 (0x1)'}
The media is writable. {'2 (0x2)'}
The media is readable and writable. {'3 (0x3)'}
"Write once" media. {'4 (0x4)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "Access". The latter is defined
# by the hashtable in $Access:
Select-Object -Property Caption, $Access
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAccess
{
_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.
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Access
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Access**
[EnumAccess]$rawValue
# get a comma-separated string:
[EnumAccess]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumAccess]
#endregion
Enums must cover all possible values. If Access returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
Automount
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.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Automount
Availability
Describes the availability and status of the device. Inherited from CIM_LogicalDevice. This can be one of the following values.
Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$Availability_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Running or Full Power = '3 (0x3)'
Warning = '4 (0x4)'
In Test = '5 (0x5)'
Not Applicable = '6 (0x6)'
Power Off = '7 (0x7)'
Offline = '8 (0x8)'
Off Duty = '9 (0x9)'
Degraded = '10 (0xA)'
Not Installed = '11 (0xB)'
Install Error = '12 (0xC)'
Power Save - Unknown The device is known to be in a power save mode, but its exact status is unknown. = '13 (0xD)'
Power Save - Low Power Mode The device is in a power save state, but still functioning, and may exhibit degraded performance. = '14 (0xE)'
Power Save - Standby The device is not functioning, but could be brought to full power quickly. = '15 (0xF)'
Power Cycle = '16 (0x10)'
Power Save - Warning The device is in a warning state, but also in a power save mode. = '17 (0x11)'
Paused = '18 (0x12)'
Not Ready = '19 (0x13)'
Not Configured = '20 (0x14)'
Quiesced = '21 (0x15)'
}
Use a switch statement
switch([int]$value)
{
Other {'1 (0x1)'}
Unknown {'2 (0x2)'}
Running or Full Power {'3 (0x3)'}
Warning {'4 (0x4)'}
In Test {'5 (0x5)'}
Not Applicable {'6 (0x6)'}
Power Off {'7 (0x7)'}
Offline {'8 (0x8)'}
Off Duty {'9 (0x9)'}
Degraded {'10 (0xA)'}
Not Installed {'11 (0xB)'}
Install Error {'12 (0xC)'}
Power Save - Unknown The device is known to be in a power save mode, but its exact status is unknown. {'13 (0xD)'}
Power Save - Low Power Mode The device is in a power save state, but still functioning, and may exhibit degraded performance. {'14 (0xE)'}
Power Save - Standby The device is not functioning, but could be brought to full power quickly. {'15 (0xF)'}
Power Cycle {'16 (0x10)'}
Power Save - Warning The device is in a warning state, but also in a power save mode. {'17 (0x11)'}
Paused {'18 (0x12)'}
Not Ready {'19 (0x13)'}
Not Configured {'20 (0x14)'}
Quiesced {'21 (0x15)'}
default {"$value"}
}
Use Enum structure
Enum EnumAvailability
{
_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
}
Examples
Use $Availability_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "Availability" to friendly text
Note: to use other properties than "Availability", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Availability"
# to translate other properties, use their translation table instead
$Availability_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Running or Full Power = '3 (0x3)'
Warning = '4 (0x4)'
In Test = '5 (0x5)'
Not Applicable = '6 (0x6)'
Power Off = '7 (0x7)'
Offline = '8 (0x8)'
Off Duty = '9 (0x9)'
Degraded = '10 (0xA)'
Not Installed = '11 (0xB)'
Install Error = '12 (0xC)'
Power Save - Unknown The device is known to be in a power save mode, but its exact status is unknown. = '13 (0xD)'
Power Save - Low Power Mode The device is in a power save state, but still functioning, and may exhibit degraded performance. = '14 (0xE)'
Power Save - Standby The device is not functioning, but could be brought to full power quickly. = '15 (0xF)'
Power Cycle = '16 (0x10)'
Power Save - Warning The device is in a warning state, but also in a power save mode. = '17 (0x11)'
Paused = '18 (0x12)'
Not Ready = '19 (0x13)'
Not Configured = '20 (0x14)'
Quiesced = '21 (0x15)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Availability", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
$Availability_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "Availability". The latter
# is defined by the hashtable in $Availability:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $Availability
# ...or dump content of property Availability:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $Availability |
Select-Object -ExpandProperty Availability
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Availability_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$Availability_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Running or Full Power = '3 (0x3)'
Warning = '4 (0x4)'
In Test = '5 (0x5)'
Not Applicable = '6 (0x6)'
Power Off = '7 (0x7)'
Offline = '8 (0x8)'
Off Duty = '9 (0x9)'
Degraded = '10 (0xA)'
Not Installed = '11 (0xB)'
Install Error = '12 (0xC)'
Power Save - Unknown The device is known to be in a power save mode, but its exact status is unknown. = '13 (0xD)'
Power Save - Low Power Mode The device is in a power save state, but still functioning, and may exhibit degraded performance. = '14 (0xE)'
Power Save - Standby The device is not functioning, but could be brought to full power quickly. = '15 (0xF)'
Power Cycle = '16 (0x10)'
Power Save - Warning The device is in a warning state, but also in a power save mode. = '17 (0x11)'
Paused = '18 (0x12)'
Not Ready = '19 (0x13)'
Not Configured = '20 (0x14)'
Quiesced = '21 (0x15)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.Availability
# translate raw value to friendly text:
$friendlyName = $Availability_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "Availability" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "Availability", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "Availability", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$Availability = @{
Name = 'Availability'
Expression = {
# property is an array, so process all values
$value = $_.Availability
switch([int]$value)
{
Other {'1 (0x1)'}
Unknown {'2 (0x2)'}
Running or Full Power {'3 (0x3)'}
Warning {'4 (0x4)'}
In Test {'5 (0x5)'}
Not Applicable {'6 (0x6)'}
Power Off {'7 (0x7)'}
Offline {'8 (0x8)'}
Off Duty {'9 (0x9)'}
Degraded {'10 (0xA)'}
Not Installed {'11 (0xB)'}
Install Error {'12 (0xC)'}
Power Save - Unknown The device is known to be in a power save mode, but its exact status is unknown. {'13 (0xD)'}
Power Save - Low Power Mode The device is in a power save state, but still functioning, and may exhibit degraded performance. {'14 (0xE)'}
Power Save - Standby The device is not functioning, but could be brought to full power quickly. {'15 (0xF)'}
Power Cycle {'16 (0x10)'}
Power Save - Warning The device is in a warning state, but also in a power save mode. {'17 (0x11)'}
Paused {'18 (0x12)'}
Not Ready {'19 (0x13)'}
Not Configured {'20 (0x14)'}
Quiesced {'21 (0x15)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "Availability". The latter is defined
# by the hashtable in $Availability:
Select-Object -Property Caption, $Availability
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumAvailability
{
_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
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.Availability
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **Availability**
[EnumAvailability]$rawValue
# get a comma-separated string:
[EnumAvailability]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumAvailability]
#endregion
Enums must cover all possible values. If Availability returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
BlockSize
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property BlockSize
Capacity
Size of the volume in bytes.
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Capacity
Caption
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Caption
Compressed
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.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Compressed
ConfigManagerErrorCode
Indicates the Win32 Configuration Manager error code. This can be one of the following values.
ConfigManagerErrorCode returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$ConfigManagerErrorCode_map = @{
This device is working properly. = '0 (0x0)'
This device is not configured correctly. = '1 (0x1)'
Windows cannot load the driver for this device. = '2 (0x2)'
The driver for this device might be corrupted, or your system may be running low on memory or other resources. = '3 (0x3)'
This device is not working properly. One of its drivers or your registry might be corrupted. = '4 (0x4)'
The driver for this device needs a resource that Windows cannot manage. = '5 (0x5)'
The boot configuration for this device conflicts with other devices. = '6 (0x6)'
Cannot filter. = '7 (0x7)'
The driver loader for the device is missing. = '8 (0x8)'
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. = '9 (0x9)'
This device cannot start. = '10 (0xA)'
This device failed. = '11 (0xB)'
This device cannot find enough free resources that it can use. = '12 (0xC)'
Windows cannot verify this device's resources. = '13 (0xD)'
This device cannot work properly until you restart your computer. = '14 (0xE)'
This device is not working properly because there is probably a re-enumeration problem. = '15 (0xF)'
Windows cannot identify all the resources this device uses. = '16 (0x10)'
This device is asking for an unknown resource type. = '17 (0x11)'
Reinstall the drivers for this device. = '18 (0x12)'
Failure using the VxD loader. = '19 (0x13)'
Your registry might be corrupted. = '20 (0x14)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. = '21 (0x15)'
This device is disabled. = '22 (0x16)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. = '23 (0x17)'
This device is not present, is not working properly, or does not have all of its drivers installed. = '24 (0x18)'
Windows is still setting up this device. = '25 (0x19)'
Windows is still setting up this device. = '26 (0x1A)'
This device does not have a valid log configuration. = '27 (0x1B)'
The drivers for this device are not installed. = '28 (0x1C)'
This device is disabled because the firmware of the device did not give it the required resources. = '29 (0x1D)'
This device is using an Interrupt Request resource that another device is using. = '30 (0x1E)'
This device is not working properly because Windows cannot load the drivers required for this device. = '31 (0x1F)'
}
Use a switch statement
switch([int]$value)
{
This device is working properly. {'0 (0x0)'}
This device is not configured correctly. {'1 (0x1)'}
Windows cannot load the driver for this device. {'2 (0x2)'}
The driver for this device might be corrupted, or your system may be running low on memory or other resources. {'3 (0x3)'}
This device is not working properly. One of its drivers or your registry might be corrupted. {'4 (0x4)'}
The driver for this device needs a resource that Windows cannot manage. {'5 (0x5)'}
The boot configuration for this device conflicts with other devices. {'6 (0x6)'}
Cannot filter. {'7 (0x7)'}
The driver loader for the device is missing. {'8 (0x8)'}
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. {'9 (0x9)'}
This device cannot start. {'10 (0xA)'}
This device failed. {'11 (0xB)'}
This device cannot find enough free resources that it can use. {'12 (0xC)'}
Windows cannot verify this device's resources. {'13 (0xD)'}
This device cannot work properly until you restart your computer. {'14 (0xE)'}
This device is not working properly because there is probably a re-enumeration problem. {'15 (0xF)'}
Windows cannot identify all the resources this device uses. {'16 (0x10)'}
This device is asking for an unknown resource type. {'17 (0x11)'}
Reinstall the drivers for this device. {'18 (0x12)'}
Failure using the VxD loader. {'19 (0x13)'}
Your registry might be corrupted. {'20 (0x14)'}
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. {'21 (0x15)'}
This device is disabled. {'22 (0x16)'}
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. {'23 (0x17)'}
This device is not present, is not working properly, or does not have all of its drivers installed. {'24 (0x18)'}
Windows is still setting up this device. {'25 (0x19)'}
Windows is still setting up this device. {'26 (0x1A)'}
This device does not have a valid log configuration. {'27 (0x1B)'}
The drivers for this device are not installed. {'28 (0x1C)'}
This device is disabled because the firmware of the device did not give it the required resources. {'29 (0x1D)'}
This device is using an Interrupt Request resource that another device is using. {'30 (0x1E)'}
This device is not working properly because Windows cannot load the drivers required for this device. {'31 (0x1F)'}
default {"$value"}
}
Use Enum structure
Enum EnumConfigManagerErrorCode
{
_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.
}
Examples
Use $ConfigManagerErrorCode_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "ConfigManagerErrorCode" to friendly text
Note: to use other properties than "ConfigManagerErrorCode", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "ConfigManagerErrorCode"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
This device is working properly. = '0 (0x0)'
This device is not configured correctly. = '1 (0x1)'
Windows cannot load the driver for this device. = '2 (0x2)'
The driver for this device might be corrupted, or your system may be running low on memory or other resources. = '3 (0x3)'
This device is not working properly. One of its drivers or your registry might be corrupted. = '4 (0x4)'
The driver for this device needs a resource that Windows cannot manage. = '5 (0x5)'
The boot configuration for this device conflicts with other devices. = '6 (0x6)'
Cannot filter. = '7 (0x7)'
The driver loader for the device is missing. = '8 (0x8)'
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. = '9 (0x9)'
This device cannot start. = '10 (0xA)'
This device failed. = '11 (0xB)'
This device cannot find enough free resources that it can use. = '12 (0xC)'
Windows cannot verify this device's resources. = '13 (0xD)'
This device cannot work properly until you restart your computer. = '14 (0xE)'
This device is not working properly because there is probably a re-enumeration problem. = '15 (0xF)'
Windows cannot identify all the resources this device uses. = '16 (0x10)'
This device is asking for an unknown resource type. = '17 (0x11)'
Reinstall the drivers for this device. = '18 (0x12)'
Failure using the VxD loader. = '19 (0x13)'
Your registry might be corrupted. = '20 (0x14)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. = '21 (0x15)'
This device is disabled. = '22 (0x16)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. = '23 (0x17)'
This device is not present, is not working properly, or does not have all of its drivers installed. = '24 (0x18)'
Windows is still setting up this device. = '25 (0x19)'
Windows is still setting up this device. = '26 (0x1A)'
This device does not have a valid log configuration. = '27 (0x1B)'
The drivers for this device are not installed. = '28 (0x1C)'
This device is disabled because the firmware of the device did not give it the required resources. = '29 (0x1D)'
This device is using an Interrupt Request resource that another device is using. = '30 (0x1E)'
This device is not working properly because Windows cannot load the drivers required for this device. = '31 (0x1F)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ConfigManagerErrorCode", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
$ConfigManagerErrorCode_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "ConfigManagerErrorCode". The latter
# is defined by the hashtable in $ConfigManagerErrorCode:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $ConfigManagerErrorCode
# ...or dump content of property ConfigManagerErrorCode:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $ConfigManagerErrorCode |
Select-Object -ExpandProperty ConfigManagerErrorCode
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $ConfigManagerErrorCode_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
This device is working properly. = '0 (0x0)'
This device is not configured correctly. = '1 (0x1)'
Windows cannot load the driver for this device. = '2 (0x2)'
The driver for this device might be corrupted, or your system may be running low on memory or other resources. = '3 (0x3)'
This device is not working properly. One of its drivers or your registry might be corrupted. = '4 (0x4)'
The driver for this device needs a resource that Windows cannot manage. = '5 (0x5)'
The boot configuration for this device conflicts with other devices. = '6 (0x6)'
Cannot filter. = '7 (0x7)'
The driver loader for the device is missing. = '8 (0x8)'
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. = '9 (0x9)'
This device cannot start. = '10 (0xA)'
This device failed. = '11 (0xB)'
This device cannot find enough free resources that it can use. = '12 (0xC)'
Windows cannot verify this device's resources. = '13 (0xD)'
This device cannot work properly until you restart your computer. = '14 (0xE)'
This device is not working properly because there is probably a re-enumeration problem. = '15 (0xF)'
Windows cannot identify all the resources this device uses. = '16 (0x10)'
This device is asking for an unknown resource type. = '17 (0x11)'
Reinstall the drivers for this device. = '18 (0x12)'
Failure using the VxD loader. = '19 (0x13)'
Your registry might be corrupted. = '20 (0x14)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. = '21 (0x15)'
This device is disabled. = '22 (0x16)'
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. = '23 (0x17)'
This device is not present, is not working properly, or does not have all of its drivers installed. = '24 (0x18)'
Windows is still setting up this device. = '25 (0x19)'
Windows is still setting up this device. = '26 (0x1A)'
This device does not have a valid log configuration. = '27 (0x1B)'
The drivers for this device are not installed. = '28 (0x1C)'
This device is disabled because the firmware of the device did not give it the required resources. = '29 (0x1D)'
This device is using an Interrupt Request resource that another device is using. = '30 (0x1E)'
This device is not working properly because Windows cannot load the drivers required for this device. = '31 (0x1F)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.ConfigManagerErrorCode
# translate raw value to friendly text:
$friendlyName = $ConfigManagerErrorCode_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "ConfigManagerErrorCode" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "ConfigManagerErrorCode", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "ConfigManagerErrorCode", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$ConfigManagerErrorCode = @{
Name = 'ConfigManagerErrorCode'
Expression = {
# property is an array, so process all values
$value = $_.ConfigManagerErrorCode
switch([int]$value)
{
This device is working properly. {'0 (0x0)'}
This device is not configured correctly. {'1 (0x1)'}
Windows cannot load the driver for this device. {'2 (0x2)'}
The driver for this device might be corrupted, or your system may be running low on memory or other resources. {'3 (0x3)'}
This device is not working properly. One of its drivers or your registry might be corrupted. {'4 (0x4)'}
The driver for this device needs a resource that Windows cannot manage. {'5 (0x5)'}
The boot configuration for this device conflicts with other devices. {'6 (0x6)'}
Cannot filter. {'7 (0x7)'}
The driver loader for the device is missing. {'8 (0x8)'}
This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly. {'9 (0x9)'}
This device cannot start. {'10 (0xA)'}
This device failed. {'11 (0xB)'}
This device cannot find enough free resources that it can use. {'12 (0xC)'}
Windows cannot verify this device's resources. {'13 (0xD)'}
This device cannot work properly until you restart your computer. {'14 (0xE)'}
This device is not working properly because there is probably a re-enumeration problem. {'15 (0xF)'}
Windows cannot identify all the resources this device uses. {'16 (0x10)'}
This device is asking for an unknown resource type. {'17 (0x11)'}
Reinstall the drivers for this device. {'18 (0x12)'}
Failure using the VxD loader. {'19 (0x13)'}
Your registry might be corrupted. {'20 (0x14)'}
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device. {'21 (0x15)'}
This device is disabled. {'22 (0x16)'}
System failure. Try changing the driver for this device. If that does not work, see your hardware documentation. {'23 (0x17)'}
This device is not present, is not working properly, or does not have all of its drivers installed. {'24 (0x18)'}
Windows is still setting up this device. {'25 (0x19)'}
Windows is still setting up this device. {'26 (0x1A)'}
This device does not have a valid log configuration. {'27 (0x1B)'}
The drivers for this device are not installed. {'28 (0x1C)'}
This device is disabled because the firmware of the device did not give it the required resources. {'29 (0x1D)'}
This device is using an Interrupt Request resource that another device is using. {'30 (0x1E)'}
This device is not working properly because Windows cannot load the drivers required for this device. {'31 (0x1F)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "ConfigManagerErrorCode". The latter is defined
# by the hashtable in $ConfigManagerErrorCode:
Select-Object -Property Caption, $ConfigManagerErrorCode
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumConfigManagerErrorCode
{
_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.
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.ConfigManagerErrorCode
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **ConfigManagerErrorCode**
[EnumConfigManagerErrorCode]$rawValue
# get a comma-separated string:
[EnumConfigManagerErrorCode]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumConfigManagerErrorCode]
#endregion
Enums must cover all possible values. If ConfigManagerErrorCode returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ConfigManagerUserConfig
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property ConfigManagerUserConfig
CreationClassName
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property CreationClassName
Description
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Description
DeviceID
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property DeviceID
DirtyBitSet
If true, the Chkdsk method is automatically run by the system at the next restart.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property DirtyBitSet
DriveLetter
Drive letter assigned to a volume. This property is NULL for volumes without drive letters.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property DriveLetter
DriveType
Numeric value that corresponds to the type of disk drive that this logical disk represents.
The values are:
DriveType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$DriveType_map = @{
Unknown = '0 (0x0)'
No Root Directory = '1 (0x1)'
Removable Disk = '2 (0x2)'
Local Disk = '3 (0x3)'
Network Drive = '4 (0x4)'
Compact Disk = '5 (0x5)'
RAM Disk = '6 (0x6)'
}
Use a switch statement
switch([int]$value)
{
Unknown {'0 (0x0)'}
No Root Directory {'1 (0x1)'}
Removable Disk {'2 (0x2)'}
Local Disk {'3 (0x3)'}
Network Drive {'4 (0x4)'}
Compact Disk {'5 (0x5)'}
RAM Disk {'6 (0x6)'}
default {"$value"}
}
Use Enum structure
Enum EnumDriveType
{
_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
}
Examples
Use $DriveType_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "DriveType" to friendly text
Note: to use other properties than "DriveType", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "DriveType"
# to translate other properties, use their translation table instead
$DriveType_map = @{
Unknown = '0 (0x0)'
No Root Directory = '1 (0x1)'
Removable Disk = '2 (0x2)'
Local Disk = '3 (0x3)'
Network Drive = '4 (0x4)'
Compact Disk = '5 (0x5)'
RAM Disk = '6 (0x6)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DriveType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DriveType = @{
Name = 'DriveType'
Expression = {
# property is an array, so process all values
$value = $_.DriveType
$DriveType_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "DriveType". The latter
# is defined by the hashtable in $DriveType:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $DriveType
# ...or dump content of property DriveType:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $DriveType |
Select-Object -ExpandProperty DriveType
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DriveType_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$DriveType_map = @{
Unknown = '0 (0x0)'
No Root Directory = '1 (0x1)'
Removable Disk = '2 (0x2)'
Local Disk = '3 (0x3)'
Network Drive = '4 (0x4)'
Compact Disk = '5 (0x5)'
RAM Disk = '6 (0x6)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.DriveType
# translate raw value to friendly text:
$friendlyName = $DriveType_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "DriveType" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "DriveType", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "DriveType", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$DriveType = @{
Name = 'DriveType'
Expression = {
# property is an array, so process all values
$value = $_.DriveType
switch([int]$value)
{
Unknown {'0 (0x0)'}
No Root Directory {'1 (0x1)'}
Removable Disk {'2 (0x2)'}
Local Disk {'3 (0x3)'}
Network Drive {'4 (0x4)'}
Compact Disk {'5 (0x5)'}
RAM Disk {'6 (0x6)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "DriveType". The latter is defined
# by the hashtable in $DriveType:
Select-Object -Property Caption, $DriveType
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumDriveType
{
_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
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.DriveType
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **DriveType**
[EnumDriveType]$rawValue
# get a comma-separated string:
[EnumDriveType]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumDriveType]
#endregion
Enums must cover all possible values. If DriveType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
ErrorCleared
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property ErrorCleared
ErrorDescription
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property ErrorDescription
ErrorMethodology
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property ErrorMethodology
FileSystem
File system on the logical disk.
Example: NTFS
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property FileSystem
FreeSpace
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property FreeSpace
IndexingEnabled
If true, context indexing is enabled.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property IndexingEnabled
InstallDate
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property InstallDate
Label
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.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Label
LastErrorCode
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property LastErrorCode
MaximumFileNameLength
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
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property MaximumFileNameLength
Name
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Name
NumberOfBlocks
For more information about using uint64 values in scripts, see Scripting in WMI.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property NumberOfBlocks
PNPDeviceID
Indicates the Win32 Plug and Play device ID of the logical device. Example: *PNP030b.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property PNPDeviceID
PowerManagementCapabilities
Indicates the specific power-related capabilities of the logical device. This can be one of the following values.
PowerManagementCapabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$PowerManagementCapabilities_map = @{
Unknown = '0 (0x0)'
Not Supported = '1 (0x1)'
Disabled = '2 (0x2)'
Enabled The power management features are currently enabled but the exact feature set is unknown or the information is unavailable. = '3 (0x3)'
Power Saving Modes Entered Automatically The device can change its power state based on usage or other criteria. = '4 (0x4)'
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. = '5 (0x5)'
Power Cycling Supported The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle). = '6 (0x6)'
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. = '7 (0x7)'
}
Use a switch statement
switch([int]$value)
{
Unknown {'0 (0x0)'}
Not Supported {'1 (0x1)'}
Disabled {'2 (0x2)'}
Enabled The power management features are currently enabled but the exact feature set is unknown or the information is unavailable. {'3 (0x3)'}
Power Saving Modes Entered Automatically The device can change its power state based on usage or other criteria. {'4 (0x4)'}
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. {'5 (0x5)'}
Power Cycling Supported The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle). {'6 (0x6)'}
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. {'7 (0x7)'}
default {"$value"}
}
Use Enum structure
Enum EnumPowerManagementCapabilities
{
_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.
}
Examples
Use $PowerManagementCapabilities_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "PowerManagementCapabilities" to friendly text
Note: to use other properties than "PowerManagementCapabilities", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "PowerManagementCapabilities"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
Unknown = '0 (0x0)'
Not Supported = '1 (0x1)'
Disabled = '2 (0x2)'
Enabled The power management features are currently enabled but the exact feature set is unknown or the information is unavailable. = '3 (0x3)'
Power Saving Modes Entered Automatically The device can change its power state based on usage or other criteria. = '4 (0x4)'
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. = '5 (0x5)'
Power Cycling Supported The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle). = '6 (0x6)'
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. = '7 (0x7)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "PowerManagementCapabilities", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$value = $_.PowerManagementCapabilities
$PowerManagementCapabilities_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "PowerManagementCapabilities". The latter
# is defined by the hashtable in $PowerManagementCapabilities:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $PowerManagementCapabilities
# ...or dump content of property PowerManagementCapabilities:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $PowerManagementCapabilities |
Select-Object -ExpandProperty PowerManagementCapabilities
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $PowerManagementCapabilities_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$PowerManagementCapabilities_map = @{
Unknown = '0 (0x0)'
Not Supported = '1 (0x1)'
Disabled = '2 (0x2)'
Enabled The power management features are currently enabled but the exact feature set is unknown or the information is unavailable. = '3 (0x3)'
Power Saving Modes Entered Automatically The device can change its power state based on usage or other criteria. = '4 (0x4)'
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. = '5 (0x5)'
Power Cycling Supported The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle). = '6 (0x6)'
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. = '7 (0x7)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.PowerManagementCapabilities
# translate raw value to friendly text:
$friendlyName = $PowerManagementCapabilities_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "PowerManagementCapabilities" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "PowerManagementCapabilities", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "PowerManagementCapabilities", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$PowerManagementCapabilities = @{
Name = 'PowerManagementCapabilities'
Expression = {
# property is an array, so process all values
$value = $_.PowerManagementCapabilities
switch([int]$value)
{
Unknown {'0 (0x0)'}
Not Supported {'1 (0x1)'}
Disabled {'2 (0x2)'}
Enabled The power management features are currently enabled but the exact feature set is unknown or the information is unavailable. {'3 (0x3)'}
Power Saving Modes Entered Automatically The device can change its power state based on usage or other criteria. {'4 (0x4)'}
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. {'5 (0x5)'}
Power Cycling Supported The SetPowerState method can be invoked with the PowerState parameter set to 5 (Power Cycle). {'6 (0x6)'}
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. {'7 (0x7)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "PowerManagementCapabilities". The latter is defined
# by the hashtable in $PowerManagementCapabilities:
Select-Object -Property Caption, $PowerManagementCapabilities
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumPowerManagementCapabilities
{
_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.
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.PowerManagementCapabilities
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **PowerManagementCapabilities**
[EnumPowerManagementCapabilities]$rawValue
# get a comma-separated string:
[EnumPowerManagementCapabilities]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumPowerManagementCapabilities]
#endregion
Enums must cover all possible values. If PowerManagementCapabilities returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
PowerManagementSupported
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property PowerManagementSupported
Purpose
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Purpose
QuotasEnabled
If true, quota management is enabled for this volume.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property QuotasEnabled
QuotasIncomplete
If true, quota management was used but is disabled. Incomplete refers to the information left in the file system after quota management is disabled.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property QuotasIncomplete
QuotasRebuilding
If true, the file system is in the process of compiling information and setting the disk up for quota management.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property QuotasRebuilding
SerialNumber
Serial number of the volume.
Example: A8C3D032
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property SerialNumber
Status
Current status of an object. Various operational and nonoperational statuses can be defined. Available values:
$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property Status
StatusInfo
Indicates the state of the logical device. This can be one of the following values.
StatusInfo returns a numeric value. To translate it into a meaningful text, use any of the following approaches:
Use a PowerShell Hashtable
$StatusInfo_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Enabled = '3 (0x3)'
Disabled = '4 (0x4)'
Not Applicable = '5 (0x5)'
}
Use a switch statement
switch([int]$value)
{
Other {'1 (0x1)'}
Unknown {'2 (0x2)'}
Enabled {'3 (0x3)'}
Disabled {'4 (0x4)'}
Not Applicable {'5 (0x5)'}
default {"$value"}
}
Use Enum structure
Enum EnumStatusInfo
{
_1_0x1 = Other
_2_0x2 = Unknown
_3_0x3 = Enabled
_4_0x4 = Disabled
_5_0x5 = Not Applicable
}
Examples
Use $StatusInfo_map in a calculated property for Select-Object
<#
this example uses a hashtable to translate raw numeric values for
property "StatusInfo" to friendly text
Note: to use other properties than "StatusInfo", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "StatusInfo"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Enabled = '3 (0x3)'
Disabled = '4 (0x4)'
Not Applicable = '5 (0x5)'
}
#endregion define hashtable
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "StatusInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
$StatusInfo_map[[int]$value]
}
}
#endregion define calculated property
# retrieve the instances, and output the properties "Caption" and "StatusInfo". The latter
# is defined by the hashtable in $StatusInfo:
Get-CimInstance -Class Win32_Volume | Select-Object -Property Caption, $StatusInfo
# ...or dump content of property StatusInfo:
$friendlyValues = Get-CimInstance -Class Win32_Volume |
Select-Object -Property $StatusInfo |
Select-Object -ExpandProperty StatusInfo
# output values
$friendlyValues
# output values as comma separated list
$friendlyValues -join ', '
# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $StatusInfo_map to directly translate raw values from an instance
<#
this example uses a hashtable to manually translate raw numeric values
for property "Win32_Volume" to friendly text. This approach is ideal when
there is just one instance to work with.
Note: to use other properties than "Win32_Volume", look up the appropriate
translation hashtable for the property you would like to use instead.
#>
#region define hashtable to translate raw values to friendly text
# Please note: this hashtable is specific for property "Win32_Volume"
# to translate other properties, use their translation table instead
$StatusInfo_map = @{
Other = '1 (0x1)'
Unknown = '2 (0x2)'
Enabled = '3 (0x3)'
Disabled = '4 (0x4)'
Not Applicable = '5 (0x5)'
}
#endregion define hashtable
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to illustrate
the number-to-text translation. To process all instances, replace
"Select-Object -First 1" with a "Foreach-Object" loop, and use
the iterator variable $_ instead of $instance
#>
# query the property
$rawValue = $instance.StatusInfo
# translate raw value to friendly text:
$friendlyName = $StatusInfo_map[[int]$rawValue]
# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<#
this example uses a switch clause to translate raw numeric
values for property "StatusInfo" to friendly text. The switch
clause is embedded into a calculated property so there is
no need to refer to external variables for translation.
Note: to use other properties than "StatusInfo", look up the appropriate
translation switch clause for the property you would like to use instead.
#>
#region define calculated property (to be used with Select-Object)
<#
a calculated property is defined by a hashtable with keys "Name" and "Expression"
"Name" defines the name of the property (in this example, it is "StatusInfo", but you can rename it to anything else)
"Expression" defines a scriptblock that calculates the content of this property
in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
value to its friendly text counterpart:
#>
$StatusInfo = @{
Name = 'StatusInfo'
Expression = {
# property is an array, so process all values
$value = $_.StatusInfo
switch([int]$value)
{
Other {'1 (0x1)'}
Unknown {'2 (0x2)'}
Enabled {'3 (0x3)'}
Disabled {'4 (0x4)'}
Not Applicable {'5 (0x5)'}
default {"$value"}
}
}
}
#endregion define calculated property
# retrieve all instances...
Get-CimInstance -ClassName Win32_Volume |
# ...and output properties "Caption" and "StatusInfo". The latter is defined
# by the hashtable in $StatusInfo:
Select-Object -Property Caption, $StatusInfo
Use the Enum from above to auto-translate the code values
<#
this example translates raw values by means of type conversion
the friendly names are defined as enumeration using the
keyword "enum" (PowerShell 5 or better)
The raw value(s) are translated to friendly text by
simply converting them into the enum type.
Note: to use other properties than "Win32_Volume", look up the appropriate
enum definition for the property you would like to use instead.
#>
#region define enum with value-to-text translation:
Enum EnumStatusInfo
{
_1_0x1 = Other
_2_0x2 = Unknown
_3_0x3 = Enabled
_4_0x4 = Disabled
_5_0x5 = Not Applicable
}
#endregion define enum
# get one instance:
$instance = Get-CimInstance -Class Win32_Volume | Select-Object -First 1
<#
IMPORTANT: this example processes only one instance to focus on
the number-to-text type conversion.
To process all instances, replace "Select-Object -First 1"
with a "Foreach-Object" loop, and use the iterator variable
$_ instead of $instance
#>
# query the property:
$rawValue = $instance.StatusInfo
#region using strict type conversion
<#
Note: strict type conversion fails if the raw value is
not defined by the enum. So if the list of allowable values
was extended and the enum does not match the value,
an exception is thrown
#>
# convert the property to the enum **StatusInfo**
[EnumStatusInfo]$rawValue
# get a comma-separated string:
[EnumStatusInfo]$rawValue -join ','
#endregion
#region using operator "-as"
<#
Note: the operator "-as" accepts values not defined
by the enum and returns $null instead of throwing
an exception
#>
$rawValue -as [EnumStatusInfo]
#endregion
Enums must cover all possible values. If StatusInfo returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.
SupportsDiskQuotas
If true, the volume supports disk quotas.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property SupportsDiskQuotas
SupportsFileBasedCompression
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.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property SupportsFileBasedCompression
SystemCreationClassName
Indicates the system’s creation class name.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property SystemCreationClassName
SystemName
Indicates the system’s name.
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property SystemName
Examples
List all instances of Win32_Volume
Get-CimInstance -ClassName Win32_Volume
Learn more about Get-CimInstance
and the deprecated Get-WmiObject
.
View all properties
Get-CimInstance -ClassName Win32_Volume -Property *
View key properties only
Get-CimInstance -ClassName Win32_Volume -KeyOnly
Selecting Properties
To select only some properties, pipe the results to Select-Object -Property a,b,c
with a comma-separated list of the properties you require. Wildcards are permitted.
Get-CimInstance
always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object
if you want to limit the visible properties, i.e. for reporting.
Selecting Properties
The code below lists all available properties. Remove the ones you do not need:
$properties = 'Access',
'Automount',
'Availability',
'BlockSize',
'Capacity',
'Caption',
'Compressed',
'ConfigManagerErrorCode',
'ConfigManagerUserConfig',
'CreationClassName',
'Description',
'DeviceID',
'DirtyBitSet',
'DriveLetter',
'DriveType',
'ErrorCleared',
'ErrorDescription',
'ErrorMethodology',
'FileSystem',
'FreeSpace',
'IndexingEnabled',
'InstallDate',
'Label',
'LastErrorCode',
'MaximumFileNameLength',
'Name',
'NumberOfBlocks',
'PNPDeviceID',
'PowerManagementCapabilities',
'PowerManagementSupported',
'Purpose',
'QuotasEnabled',
'QuotasIncomplete',
'QuotasRebuilding',
'SerialNumber',
'Status',
'StatusInfo',
'SupportsDiskQuotas',
'SupportsFileBasedCompression',
'SystemCreationClassName',
'SystemName'
Get-CimInstance -ClassName Win32_Volume | Select-Object -Property $properties
Limiting Network Bandwidth
If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:
Get-CimInstance -Class Win32_Volume -Property $property |
Select-Object -Property $property
Selecting Instances
To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).
The parameter -Filter runs a simple query.
Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_Volume -Filter 'Caption LIKE "a%"'
Using a WQL Query
The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:
Get-CimInstance -Query "SELECT CreationClassName, LastErrorCode, QuotasIncomplete, NumberOfBlocks FROM Win32_Volume WHERE Caption LIKE 'a%'"
Any property you did not specify is still present but empty. You might need to use
Select-Object
to remove all unwanted properties:Get-CimInstance -Query "SELECT CreationClassName, LastErrorCode, QuotasIncomplete, NumberOfBlocks FROM Win32_Volume WHERE Caption LIKE 'a%'" | Select-Object -Property CreationClassName, LastErrorCode, QuotasIncomplete, NumberOfBlocks
Accessing Remote Computers
To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.
Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_Volume -ComputerName $list
$result
Authenticating as Different User
Use a CIMSession object to authenticate with a new identity:
# one or more computer names or IP addresses:
$list = 'server1', 'server2'
# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred
$result = Get-CimInstance Win32_Volume -CimSession $session
# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session
$result
Learn more about accessing remote computers.
Requirements
To use Win32_Volume, the following requirements apply:
PowerShell
Get-CimInstance
was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.
If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.
Operating System
Win32_Volume was introduced on clients with None supported and on servers with Windows Server 2003.
Namespace
Win32_Volume lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance
.
Implementation
Win32_Volume is implemented in Vdswmi.dll and defined in Vds.mof. Both files are located in the folder C:\Windows\system32\wbem
:
explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\Vds.mof