Win32_CDROMDrive

The Win32_CDROMDrive WMI class represents a CD-ROM drive on a computer system running Windows.

The Win32_CDROMDrive WMI class represents a CD-ROM drive on a computer system running Windows.

Methods

Win32_CDROMDrive has no methods. Inherited methods (Reset and SetPowerState) are not implemented.

Properties

Win32_CDROMDrive returns 18 properties:

'Availability','Capabilities','CapabilityDescriptions','Caption','CompressionMethod',
'ConfigManagerErrorCode','ConfigManagerUserConfig','CreationClassName','DefaultBlockSize','Description',
'DeviceID','Drive','DriveIntegrity','ErrorCleared','ErrorDescription','ErrorMethodology',
'FileSystemFlags','FileSystemFlagsEx'

Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:

Get-CimInstance -ClassName Win32_CDROMDrive -Property *

Most WMI classes return one or more instances.

When Get-CimInstance returns no result, then apparently no instances of class Win32_CDROMDrive 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).

Availability

UINT16

Availability and status of the device.

Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$Availability_map = @{
      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'
}
Use a switch statement
switch([int]$value)
{
  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'}
  default    {"$value"}
}
Use Enum structure
Enum EnumAvailability
{
  Other                       = 1
  Unknown                     = 2
  RunningFull_Power           = 3
  Warning                     = 4
  In_Test                     = 5
  Not_Applicable              = 6
  Power_Off                   = 7
  Off_Line                    = 8
  Off_Duty                    = 9
  Degraded                    = 10
  Not_Installed               = 11
  Install_Error               = 12
  Power_Save_Unknown          = 13
  Power_Save_Low_Power_Mode   = 14
  Power_Save_Standby          = 15
  Power_Cycle                 = 16
  Power_Save_Warning          = 17
  Paused                      = 18
  Not_Ready                   = 19
  Not_Configured              = 20
  Quiesced                    = 21
}

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 = @{
      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'
}

#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_CDROMDrive | Select-Object -Property Caption, $Availability

# ...or dump content of property Availability:
$friendlyValues = Get-CimInstance -Class Win32_CDROMDrive | 
    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_CDROMDrive" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_CDROMDrive", 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_CDROMDrive" 
# to translate other properties, use their translation table instead
$Availability_map = @{
      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'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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)
      {
        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'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_CDROMDrive | 
  # ...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_CDROMDrive", 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
{
  Other                       = 1
  Unknown                     = 2
  RunningFull_Power           = 3
  Warning                     = 4
  In_Test                     = 5
  Not_Applicable              = 6
  Power_Off                   = 7
  Off_Line                    = 8
  Off_Duty                    = 9
  Degraded                    = 10
  Not_Installed               = 11
  Install_Error               = 12
  Power_Save_Unknown          = 13
  Power_Save_Low_Power_Mode   = 14
  Power_Save_Standby          = 15
  Power_Cycle                 = 16
  Power_Save_Warning          = 17
  Paused                      = 18
  Not_Ready                   = 19
  Not_Configured              = 20
  Quiesced                    = 21
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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.

Capabilities

UINT16 ARRAY

Array of capabilities of the media access device. For example, the device may support random access (3), removable media (7), and automatic cleaning (9).

Capabilities returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$Capabilities_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Sequential Access'
      3 = 'Random Access'
      4 = 'Supports Writing'
      5 = 'Encryption'
      6 = 'Compression'
      7 = 'Supports Removeable Media'
      8 = 'Manual Cleaning'
      9 = 'Automatic Cleaning'
     10 = 'SMART Notification'
     11 = 'Supports Dual Sided Media'
     12 = 'Predismount Eject Not Required'
}
Use a switch statement
switch([int]$value)
{
  0          {'Unknown'}
  1          {'Other'}
  2          {'Sequential Access'}
  3          {'Random Access'}
  4          {'Supports Writing'}
  5          {'Encryption'}
  6          {'Compression'}
  7          {'Supports Removeable Media'}
  8          {'Manual Cleaning'}
  9          {'Automatic Cleaning'}
  10         {'SMART Notification'}
  11         {'Supports Dual Sided Media'}
  12         {'Predismount Eject Not Required'}
  default    {"$value"}
}
Use Enum structure
Enum EnumCapabilities
{
  Unknown                          = 0
  Other                            = 1
  Sequential_Access                = 2
  Random_Access                    = 3
  Supports_Writing                 = 4
  Encryption                       = 5
  Compression                      = 6
  Supports_Removeable_Media        = 7
  Manual_Cleaning                  = 8
  Automatic_Cleaning               = 9
  SMART_Notification               = 10
  Supports_Dual_Sided_Media        = 11
  Predismount_Eject_Not_Required   = 12
}

Examples

Use $Capabilities_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "Capabilities" to friendly text

  Note: to use other properties than "Capabilities", 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 "Capabilities" 
# to translate other properties, use their translation table instead
$Capabilities_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Sequential Access'
      3 = 'Random Access'
      4 = 'Supports Writing'
      5 = 'Encryption'
      6 = 'Compression'
      7 = 'Supports Removeable Media'
      8 = 'Manual Cleaning'
      9 = 'Automatic Cleaning'
     10 = 'SMART Notification'
     11 = 'Supports Dual Sided Media'
     12 = 'Predismount Eject Not Required'
}

#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 "Capabilities", 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:
#>
 
$Capabilities = @{
  Name = 'Capabilities'
  Expression = {
    # property is an array, so process all values
    $result = foreach($value in $_.Capabilities)
    {
        # important: convert original value to [int] because
        # hashtable keys are type-aware:
        $Capabilities_map[[int]$value]
    }
    # uncomment to get a comma-separated string instead
    # of a string array:
    $result <#-join ', '#>
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "Capabilities". The latter
# is defined by the hashtable in $Capabilities: 
Get-CimInstance -Class Win32_CDROMDrive | Select-Object -Property Caption, $Capabilities

# ...or dump content of property Capabilities:
$friendlyValues = Get-CimInstance -Class Win32_CDROMDrive | 
    Select-Object -Property $Capabilities |
    Select-Object -ExpandProperty Capabilities

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $Capabilities_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_CDROMDrive" to friendly text. This approach is ideal when there
  is just one instance to work with.

  Note: to use other properties than "Win32_CDROMDrive", 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_CDROMDrive" 
# to translate other properties, use their translation table instead
$Capabilities_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Sequential Access'
      3 = 'Random Access'
      4 = 'Supports Writing'
      5 = 'Encryption'
      6 = 'Compression'
      7 = 'Supports Removeable Media'
      8 = 'Manual Cleaning'
      9 = 'Automatic Cleaning'
     10 = 'SMART Notification'
     11 = 'Supports Dual Sided Media'
     12 = 'Predismount Eject Not Required'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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 (hint: the property is an array!)
$rawValues = $instance.Capabilities  

# translate all raw values into friendly names:
$friendlyNames = foreach($rawValue in $rawValues)
{ $Capabilities_map[[int]$rawValue] }

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "Capabilities" 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 "Capabilities", 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 "Capabilities", 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:
#>
 
$Capabilities = @{
  Name = 'Capabilities'
  Expression = {
    # property is an array, so process all values
    $result = foreach($value in $_.Capabilities)
    {
        switch([int]$value)
      {
        0          {'Unknown'}
        1          {'Other'}
        2          {'Sequential Access'}
        3          {'Random Access'}
        4          {'Supports Writing'}
        5          {'Encryption'}
        6          {'Compression'}
        7          {'Supports Removeable Media'}
        8          {'Manual Cleaning'}
        9          {'Automatic Cleaning'}
        10         {'SMART Notification'}
        11         {'Supports Dual Sided Media'}
        12         {'Predismount Eject Not Required'}
        default    {"$value"}
      }
      
    }
    $result
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_CDROMDrive | 
  # ...and output properties "Caption" and "Capabilities". The latter is defined
  # by the hashtable in $Capabilities:
  Select-Object -Property Caption, $Capabilities
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_CDROMDrive", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumCapabilities
{
  Unknown                          = 0
  Other                            = 1
  Sequential_Access                = 2
  Random_Access                    = 3
  Supports_Writing                 = 4
  Encryption                       = 5
  Compression                      = 6
  Supports_Removeable_Media        = 7
  Manual_Cleaning                  = 8
  Automatic_Cleaning               = 9
  SMART_Notification               = 10
  Supports_Dual_Sided_Media        = 11
  Predismount_Eject_Not_Required   = 12
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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.Capabilities

#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 **Capabilities** 
[EnumCapabilities[]]$rawValue 

# get a comma-separated string:
[EnumCapabilities[]]$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 [EnumCapabilities[]]
#endregion

Enums must cover all possible values. If Capabilities 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.

CapabilityDescriptions

STRING ARRAY

Array of more detailed explanations for any of the access device features indicated in the Capabilities array. Each entry of this array is related to the entry in the Capabilities array that is located at the same index.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, CapabilityDescriptions

Caption

STRING MAX 64 CHAR

Short description of the object a one-line string.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, Caption

CompressionMethod

STRING

Algorithm or tool used by the device to support compression. If it is not possible or not desired to describe the compression scheme (perhaps because it is not known), use the following words: “Unknown” to represent that it is not known whether the device supports compression capabilities; “Compressed” to represent that the device supports compression capabilities but either its compression scheme is not known or not disclosed; and “Not Compressed” to represent that the device does not support compression capabilities.

(“Unknown”)

The compression scheme is unknown or not described.

(“Compressed”)

The logical file is compressed, but the compression scheme is unknown or not described

(“Not Compressed”)

If the logical file is not compressed

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, CompressionMethod

ConfigManagerErrorCode

UINT32

Windows Configuration Manager error code.

ConfigManagerErrorCode returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$ConfigManagerErrorCode_map = @{
      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 system may be running low on memory or other resources.'
      4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
      5 = 'The driver for this device needs a resource that Windows cannot manage.'
      6 = 'The boot configuration for this device conflicts with other devices.'
      7 = 'Cannot filter.'
      8 = 'The driver loader for the device is missing.'
      9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
     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 computer.'
     15 = 'This device is not working properly because there is probably a re-enumeration problem.'
     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. If that does not work, see your hardware documentation. Windows is removing this device.'
     22 = 'This device is disabled.'
     23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
     24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
     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 did not give it the required resources.'
     30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
     31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}
Use a switch statement
switch([int]$value)
{
  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 system may be running low on memory or other resources.'}
  4          {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
  5          {'The driver for this device needs a resource that Windows cannot manage.'}
  6          {'The boot configuration for this device conflicts with other devices.'}
  7          {'Cannot filter.'}
  8          {'The driver loader for the device is missing.'}
  9          {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
  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 computer.'}
  15         {'This device is not working properly because there is probably a re-enumeration problem.'}
  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. If that does not work, see your hardware documentation. Windows is removing this device.'}
  22         {'This device is disabled.'}
  23         {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
  24         {'This device is not present, is not working properly, or does not have all its drivers installed.'}
  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 did not give it the required resources.'}
  30         {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
  31         {'This device is not working properly because Windows cannot load the drivers required for this device.'}
  default    {"$value"}
}
Use Enum structure
Enum EnumConfigManagerErrorCode
{
  This_device_is_working_properly                              = 0
  This_device_is_not_configured_correctly                      = 1
  Windows_cannot_load_the_driver_for_this_device               = 2
  The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
  This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
  The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
  The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
  Cannot_filter                                                = 7
  The_driver_loader_for_the_device_is_missing                  = 8
  This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
  This_device_cannot_start                                     = 10
  This_device_failed                                           = 11
  This_device_cannot_find_enough_free_resources_that_it_can_use = 12
  Windows_cannot_verify_this_devices_resources                 = 13
  This_device_cannot_work_properly_until_you_restart_your_computer = 14
  This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
  Windows_cannot_identify_all_the_resources_this_device_uses   = 16
  This_device_is_asking_for_an_unknown_resource_type           = 17
  Reinstall_the_drivers_for_this_device                        = 18
  Failure_using_the_VxD_loader                                 = 19
  Your_registry_might_be_corrupted                             = 20
  System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
  This_device_is_disabled                                      = 22
  System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
  This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
  Windows_is_still_setting_up_this_device1                     = 25
  Windows_is_still_setting_up_this_device2                     = 26
  This_device_does_not_have_valid_log_configuration            = 27
  The_drivers_for_this_device_are_not_installed                = 28
  This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
  This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
  This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}

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 = @{
      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 system may be running low on memory or other resources.'
      4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
      5 = 'The driver for this device needs a resource that Windows cannot manage.'
      6 = 'The boot configuration for this device conflicts with other devices.'
      7 = 'Cannot filter.'
      8 = 'The driver loader for the device is missing.'
      9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
     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 computer.'
     15 = 'This device is not working properly because there is probably a re-enumeration problem.'
     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. If that does not work, see your hardware documentation. Windows is removing this device.'
     22 = 'This device is disabled.'
     23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
     24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
     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 did not give it the required resources.'
     30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
     31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}

#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_CDROMDrive | Select-Object -Property Caption, $ConfigManagerErrorCode

# ...or dump content of property ConfigManagerErrorCode:
$friendlyValues = Get-CimInstance -Class Win32_CDROMDrive | 
    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_CDROMDrive" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_CDROMDrive", 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_CDROMDrive" 
# to translate other properties, use their translation table instead
$ConfigManagerErrorCode_map = @{
      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 system may be running low on memory or other resources.'
      4 = 'This device is not working properly. One of its drivers or your registry might be corrupted.'
      5 = 'The driver for this device needs a resource that Windows cannot manage.'
      6 = 'The boot configuration for this device conflicts with other devices.'
      7 = 'Cannot filter.'
      8 = 'The driver loader for the device is missing.'
      9 = 'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'
     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 computer.'
     15 = 'This device is not working properly because there is probably a re-enumeration problem.'
     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. If that does not work, see your hardware documentation. Windows is removing this device.'
     22 = 'This device is disabled.'
     23 = 'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'
     24 = 'This device is not present, is not working properly, or does not have all its drivers installed.'
     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 did not give it the required resources.'
     30 = 'This device is using an Interrupt Request (IRQ) resource that another device is using.'
     31 = 'This device is not working properly because Windows cannot load the drivers required for this device.'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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)
      {
        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 system may be running low on memory or other resources.'}
        4          {'This device is not working properly. One of its drivers or your registry might be corrupted.'}
        5          {'The driver for this device needs a resource that Windows cannot manage.'}
        6          {'The boot configuration for this device conflicts with other devices.'}
        7          {'Cannot filter.'}
        8          {'The driver loader for the device is missing.'}
        9          {'This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.'}
        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 computer.'}
        15         {'This device is not working properly because there is probably a re-enumeration problem.'}
        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. If that does not work, see your hardware documentation. Windows is removing this device.'}
        22         {'This device is disabled.'}
        23         {'System failure: Try changing the driver for this device. If that doesn''t work, see your hardware documentation.'}
        24         {'This device is not present, is not working properly, or does not have all its drivers installed.'}
        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 did not give it the required resources.'}
        30         {'This device is using an Interrupt Request (IRQ) resource that another device is using.'}
        31         {'This device is not working properly because Windows cannot load the drivers required for this device.'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_CDROMDrive | 
  # ...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_CDROMDrive", 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
{
  This_device_is_working_properly                              = 0
  This_device_is_not_configured_correctly                      = 1
  Windows_cannot_load_the_driver_for_this_device               = 2
  The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources = 3
  This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted = 4
  The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage = 5
  The_boot_configuration_for_this_device_conflicts_with_other_devices = 6
  Cannot_filter                                                = 7
  The_driver_loader_for_the_device_is_missing                  = 8
  This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly = 9
  This_device_cannot_start                                     = 10
  This_device_failed                                           = 11
  This_device_cannot_find_enough_free_resources_that_it_can_use = 12
  Windows_cannot_verify_this_devices_resources                 = 13
  This_device_cannot_work_properly_until_you_restart_your_computer = 14
  This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem = 15
  Windows_cannot_identify_all_the_resources_this_device_uses   = 16
  This_device_is_asking_for_an_unknown_resource_type           = 17
  Reinstall_the_drivers_for_this_device                        = 18
  Failure_using_the_VxD_loader                                 = 19
  Your_registry_might_be_corrupted                             = 20
  System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device = 21
  This_device_is_disabled                                      = 22
  System_failure_Try_changing_the_driver_for_this_device_If_that_doesnt_work_see_your_hardware_documentation = 23
  This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed = 24
  Windows_is_still_setting_up_this_device1                     = 25
  Windows_is_still_setting_up_this_device2                     = 26
  This_device_does_not_have_valid_log_configuration            = 27
  The_drivers_for_this_device_are_not_installed                = 28
  This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources = 29
  This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using = 30
  This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device = 31
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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

BOOLEAN

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

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, ConfigManagerUserConfig

CreationClassName

STRING

Name of the first concrete class that appears 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 identified uniquely.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, CreationClassName

DefaultBlockSize

UINT64 “BYTES”

Default block size, in bytes, for this device.

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

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, DefaultBlockSize

Description

STRING

Description of the object.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, Description

DeviceID

KEY PROPERTY STRING

Unique identifier for a CD-ROM drive.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID

Drive

STRING

Drive letter of the CD-ROM drive.

Example: “d:"

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, Drive

DriveIntegrity

BOOLEAN

If True, files can be accurately read from the CD device. This is achieved by reading a block of data twice and comparing the data against itself.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, DriveIntegrity

ErrorCleared

BOOLEAN

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

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, ErrorCleared

ErrorDescription

STRING

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

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, ErrorDescription

ErrorMethodology

STRING

Type of error detection and correction supported by this device.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, ErrorMethodology

FileSystemFlags

UINT16

This property is obsolete. In place of this property, use FileSystemFlagsEx.

Get-CimInstance -ClassName Win32_CDROMDrive | Select-Object -Property DeviceID, FileSystemFlags

FileSystemFlagsEx

UINT32

File system flags associated with the Windows CD-ROM drive. This parameter can be any combination of flags, but FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive.

FileSystemFlagsEx returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$FileSystemFlagsEx_map = @{
      1 = 'Case Sensitive Search'
      2 = 'Case Preserved Names'
      4 = 'Unicode On Disk'
      8 = 'Persistent ACLs'
     16 = 'File Compression'
     32 = 'Volume Quotas'
     64 = 'Supports Sparse Files'
    128 = 'Supports Reparse Points'
    256 = 'Supports Remote Storage'
  16384 = 'Supports Long Names'
  32768 = 'Volume Is Compressed'
 524289 = 'Read Only Volume'
  65536 = 'Supports Object IDS'
 131072 = 'Supports Encryption'
 262144 = 'Supports Named Streams'
}
Use a switch statement
switch([int]$value)
{
  1          {'Case Sensitive Search'}
  2          {'Case Preserved Names'}
  4          {'Unicode On Disk'}
  8          {'Persistent ACLs'}
  16         {'File Compression'}
  32         {'Volume Quotas'}
  64         {'Supports Sparse Files'}
  128        {'Supports Reparse Points'}
  256        {'Supports Remote Storage'}
  16384      {'Supports Long Names'}
  32768      {'Volume Is Compressed'}
  524289     {'Read Only Volume'}
  65536      {'Supports Object IDS'}
  131072     {'Supports Encryption'}
  262144     {'Supports Named Streams'}
  default    {"$value"}
}
Use Enum structure
Enum EnumFileSystemFlagsEx
{
  Case_Sensitive_Search     = 1
  Case_Preserved_Names      = 2
  Unicode_On_Disk           = 4
  Persistent_ACLs           = 8
  File_Compression          = 16
  Volume_Quotas             = 32
  Supports_Sparse_Files     = 64
  Supports_Reparse_Points   = 128
  Supports_Remote_Storage   = 256
  Supports_Long_Names       = 16384
  Volume_Is_Compressed      = 32768
  Read_Only_Volume          = 524289
  Supports_Object_IDS       = 65536
  Supports_Encryption       = 131072
  Supports_Named_Streams    = 262144
}

Examples

Use $FileSystemFlagsEx_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "FileSystemFlagsEx" to friendly text

  Note: to use other properties than "FileSystemFlagsEx", 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 "FileSystemFlagsEx" 
# to translate other properties, use their translation table instead
$FileSystemFlagsEx_map = @{
      1 = 'Case Sensitive Search'
      2 = 'Case Preserved Names'
      4 = 'Unicode On Disk'
      8 = 'Persistent ACLs'
     16 = 'File Compression'
     32 = 'Volume Quotas'
     64 = 'Supports Sparse Files'
    128 = 'Supports Reparse Points'
    256 = 'Supports Remote Storage'
  16384 = 'Supports Long Names'
  32768 = 'Volume Is Compressed'
 524289 = 'Read Only Volume'
  65536 = 'Supports Object IDS'
 131072 = 'Supports Encryption'
 262144 = 'Supports Named Streams'
}

#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 "FileSystemFlagsEx", 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:
#>
 
$FileSystemFlagsEx = @{
  Name = 'FileSystemFlagsEx'
  Expression = {
    # property is an array, so process all values
    $value = $_.FileSystemFlagsEx
    $FileSystemFlagsEx_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "FileSystemFlagsEx". The latter
# is defined by the hashtable in $FileSystemFlagsEx: 
Get-CimInstance -Class Win32_CDROMDrive | Select-Object -Property Caption, $FileSystemFlagsEx

# ...or dump content of property FileSystemFlagsEx:
$friendlyValues = Get-CimInstance -Class Win32_CDROMDrive | 
    Select-Object -Property $FileSystemFlagsEx |
    Select-Object -ExpandProperty FileSystemFlagsEx

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $FileSystemFlagsEx_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_CDROMDrive" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_CDROMDrive", 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_CDROMDrive" 
# to translate other properties, use their translation table instead
$FileSystemFlagsEx_map = @{
      1 = 'Case Sensitive Search'
      2 = 'Case Preserved Names'
      4 = 'Unicode On Disk'
      8 = 'Persistent ACLs'
     16 = 'File Compression'
     32 = 'Volume Quotas'
     64 = 'Supports Sparse Files'
    128 = 'Supports Reparse Points'
    256 = 'Supports Remote Storage'
  16384 = 'Supports Long Names'
  32768 = 'Volume Is Compressed'
 524289 = 'Read Only Volume'
  65536 = 'Supports Object IDS'
 131072 = 'Supports Encryption'
 262144 = 'Supports Named Streams'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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.FileSystemFlagsEx  

# translate raw value to friendly text:
$friendlyName = $FileSystemFlagsEx_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 "FileSystemFlagsEx" 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 "FileSystemFlagsEx", 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 "FileSystemFlagsEx", 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:
#>
 
$FileSystemFlagsEx = @{
  Name = 'FileSystemFlagsEx'
  Expression = {
    # property is an array, so process all values
    $value = $_.FileSystemFlagsEx
    
    switch([int]$value)
      {
        1          {'Case Sensitive Search'}
        2          {'Case Preserved Names'}
        4          {'Unicode On Disk'}
        8          {'Persistent ACLs'}
        16         {'File Compression'}
        32         {'Volume Quotas'}
        64         {'Supports Sparse Files'}
        128        {'Supports Reparse Points'}
        256        {'Supports Remote Storage'}
        16384      {'Supports Long Names'}
        32768      {'Volume Is Compressed'}
        524289     {'Read Only Volume'}
        65536      {'Supports Object IDS'}
        131072     {'Supports Encryption'}
        262144     {'Supports Named Streams'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_CDROMDrive | 
  # ...and output properties "Caption" and "FileSystemFlagsEx". The latter is defined
  # by the hashtable in $FileSystemFlagsEx:
  Select-Object -Property Caption, $FileSystemFlagsEx
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_CDROMDrive", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumFileSystemFlagsEx
{
  Case_Sensitive_Search     = 1
  Case_Preserved_Names      = 2
  Unicode_On_Disk           = 4
  Persistent_ACLs           = 8
  File_Compression          = 16
  Volume_Quotas             = 32
  Supports_Sparse_Files     = 64
  Supports_Reparse_Points   = 128
  Supports_Remote_Storage   = 256
  Supports_Long_Names       = 16384
  Volume_Is_Compressed      = 32768
  Read_Only_Volume          = 524289
  Supports_Object_IDS       = 65536
  Supports_Encryption       = 131072
  Supports_Named_Streams    = 262144
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_CDROMDrive | 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.FileSystemFlagsEx

#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 **FileSystemFlagsEx** 
[EnumFileSystemFlagsEx]$rawValue 

# get a comma-separated string:
[EnumFileSystemFlagsEx]$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 [EnumFileSystemFlagsEx]
#endregion

Enums must cover all possible values. If FileSystemFlagsEx 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.

Examples

List all instances of Win32_CDROMDrive
Get-CimInstance -ClassName Win32_CDROMDrive

Learn more about Get-CimInstance and the deprecated Get-WmiObject.

View all properties
Get-CimInstance -ClassName Win32_CDROMDrive -Property *
View key properties only
Get-CimInstance -ClassName Win32_CDROMDrive -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 = 'Availability',
              'Capabilities',
              'CapabilityDescriptions',
              'Caption',
              'CompressionMethod',
              'ConfigManagerErrorCode',
              'ConfigManagerUserConfig',
              'CreationClassName',
              'DefaultBlockSize',
              'Description',
              'DeviceID',
              'Drive',
              'DriveIntegrity',
              'ErrorCleared',
              'ErrorDescription',
              'ErrorMethodology',
              'FileSystemFlags',
              'FileSystemFlagsEx'
Get-CimInstance -ClassName Win32_CDROMDrive | 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_CDROMDrive -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_CDROMDrive -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 ConfigManagerUserConfig, Capabilities, Availability, ErrorCleared FROM Win32_CDROMDrive 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 ConfigManagerUserConfig, Capabilities, Availability, ErrorCleared FROM Win32_CDROMDrive WHERE Caption LIKE 'a%'" | Select-Object -Property ConfigManagerUserConfig, Capabilities, Availability, ErrorCleared

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_CDROMDrive -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_CDROMDrive -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_CDROMDrive, 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_CDROMDrive was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

Win32_CDROMDrive 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_CDROMDrive is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof